Problem inserting csv file content to MySQL Table Using Visual Studio 2008 - TechRepublic
Question
September 28, 2010 at 12:24 AM
jeffreyalejo

Problem inserting csv file content to MySQL Table Using Visual Studio 2008

by jeffreyalejo . Updated 15 years, 9 months ago

I have a csv file with the following content:

1, 029

I can insert it into the MySQL Database but the entered data looks like this:

Col1 Col2
1 29

It removes the 0 in the second column.

And here’s my connection string:

“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\UnzipFiles\;Extended Properties=’Text;HDR=No;FMT=Delimited'”

I’m inserting the value of the 2nd column of the csv file in a variable(string), then that variable is used in the insert statement to add the record. At that point, the value 029 is already changed to 29.

I tried opening the csv file with Excel and Notepad and here’s the difference:

In excel, 029 is converted to 29 while in Notepad 029 is not changed. It seems like it looks at the value of the columns based on the excel format.

Any help is highly appreciated. Thanks in advance.

Regards,

Jeff

This discussion is locked

All Comments