I am using the following code to import a csv into a datatable
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path +";Extended Properties=Text;";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM " + fileName, objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
int count = dtMain.Rows.Count;
I have a zipcode column in the csv file. The import works fine as long as the zip code is 5 digits in length. If the zip code is something like 12345-6789 after the import is completed it shows up as a blank in the zipcode column for that particular record.
Any thoughts on how I can avoid this ?