Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Double quotes in strings

Author  Topic 

tecknowledge1164
Starting Member

25 Posts

Posted - 2007-10-06 : 21:28:44
I am writing a program in Visual Basic 2005 to convert records in a delimited text file to a SQLExpress 2005 database. After querying the data from the text file I use a DataReader to loop through and insert the records to the database. I am having a problem with records that have double quotes around part of an entry, such as John "Johnny" Smith. I assign the fields to a string variable, but it seems that the fields that have the double quotes either aren't being read or can't write to the database. I have tried using the replace function using mystring = mystring.Replace("""","") but it isn't working. If someone could suggest a solution to this I would appreciate it. Thanks in advance.

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-10-08 : 09:12:19
Are you using " as a delimiter...i.e. content being mixed up with formatting?
Go to Top of Page

tecknowledge1164
Starting Member

25 Posts

Posted - 2007-10-08 : 10:05:35
The delimiter for the text file is the pipe character (|). The double quote isn't used elsewhere except for the way it would normally appear in the visual basic code, as in the example above.
Go to Top of Page

tecknowledge1164
Starting Member

25 Posts

Posted - 2007-10-08 : 17:40:27
Ok, I solved it. It was a type conversion problem, since I was coming out of the text file with strings but inserting them as integers. For some reason it was not seeing one of the values and leaving a stray comma at the end. Not quite sure why yet, but I got it to work. Thanks anyway.
Go to Top of Page
   

- Advertisement -