473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Using parameter ODBC statements

I have a block of code that will insert text into an access database.
However the text itself contains characters that make the SQL statement bomb.
The text is held in variable q. Endstring will contain multiple lines of
text. I've only shown two match statements (newsgroups and message-id).
Please help me convert this to a parameterized statement.
Thanks a ton in advance!!

string endstring =" ";
int columncount = 0;
while (true)
{
Match varb = Regex.Match(q, "Newsgroups:");
if (varb.Success)
{
columncount = columncount + 1;
if (endstring == " ")
endstring = q;
else
endstring = endstring + ", " + q;
}
Match varc = Regex.Match(q, "Message-ID:");
if (varc.Success)
{
columncount = columncount + 1;
if (endstring == " ")
endstring = q;
else
endstring = endstring + ", " + q;
}
if (q == ".") //End of Article
{
string finishedstring = " ";
if (columncount == 1)
finishedstring = "INSERT INTO Listgroup (Newsgroups) VALUES " + "("
+ endstring + ")";
if (columncount == 2)
finishedstring = "INSERT INTO Listgroup (Newsgroups, Message-ID)
VALUES " +"(" + endstring + ")";
OdbcCommand myCommand = new OdbcCommand(finishedstring, odbcConnection1);
myCommand.ExecuteNonQuery();
odbcConnection1.Close();
break;
}
Nov 16 '05 #1
0 913

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
2
by: John Jayaseelan | last post by:
Hi, The following parameter query resulted the error below. Is the following syntax correct? select * from branch where branch_code = ? COUNT field incorrect or syntax error
2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
0
by: harish | last post by:
Currently my C++ application is using ADO to connect to MS SQL Server database. Now I want to use ODBC instead of ADO. i know that i need to use window APIs I am using SQLConnect to establish...
1
by: TheKval | last post by:
I'm trying to pull records on a Macola table linked to Access. If enter a value in the criteria field of the query form, the quer executes okay. If I change the criteria to a parameter, ala, , I...
8
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY...
2
by: 111mike | last post by:
Hello, Here's my problem. I cannot connect to mysql database using odbc string connections or dns. I keep getting a "cannot connect to mysql server localhost." I'm running windows XP Pro and...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
6
by: =?Utf-8?B?LnBhdWwu?= | last post by:
how can i write to an excel .xls file using odbc? i've read in several places that its possible but i can't find an example. i have managed to read an excel file using odbc
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.