INSERT causes error

Last Post 20 Jul 2006 12:05 PM by nosepicker. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
websiteguy
New Member
New Member

--
20 Jul 2006 11:31 AM
I have a script in VB.NET that I wrote that imports data from Access to SQL server. It works fine except for one thing. My INSERT statement is like this:

INSERT INTO [MyTableName] (Product, Description, Price) Values ('" & RecSet("Product") & "', '" & RecSet("Description") & "', '" & RecSet("Price") & "')

The Description field contains a single quote( ' ) in many of the entries and this is causing an error in my script because the fields are enclosed in single quotes. Is there something else I can wrap the fields in that will stop this error from occurring?
Thanks,
Mike
websiteguy
New Member
New Member

--
20 Jul 2006 11:34 AM
I just want to add that DTS is not an option and doubling up the single quote is not an option either. There are 100s of thousands of records that already exist in the databases that will be imported with new data on a weekly basis.
Thanks,
Mike
nosepicker
New Member
New Member

--
20 Jul 2006 12:05 PM
Not sure why doubling the single quote is not an option, because that's what you really need to do. Or, get rid of it. You don't have to permanently double or get rid of the single quotes; you should be able to do it as you're inserting the data.
websiteguy
New Member
New Member

--
21 Jul 2006 04:10 AM
OK. I found a way to do it. Here is the link for anyone that may run into this problem in the future.
http://www.dotnetjunkies.com/Tutori...77861.dcik


Acceptable Use Policy
---