I am attempting to populate a DataGridView with data from a csv or comma delimited txt file the user selects. The csv gets loaded into the DataGridView, but in a certain column which contains a mixture of alpha or numeric values, if the first several values are numeric and then the data switches to alpha characters, they get dropped. See below:
Here I've imported a csv with a mix of alpha or numeric values in the cover column. The cells that should contain the alpha values are instead null.
Here I've imported a csv with only either null (the first value is supposed to be null) or alpha values. It has no issues.
It seems like perhaps there is some sort of data type guessing going on, where it thinks that the data should be numeric and nullfiies anything else.
Here's the code I'm using to import the CSV:
string conStr = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + Path.GetDirectoryName(loadPath) + ";Extensions=csv,txt";
OdbcConnection conn = new OdbcConnection(conStr);
OdbcDataAdapter da = new OdbcDataAdapter("Select * from [" + Path.GetFileName(loadPath) + "]", conn);
DataTable dt = new DataTable(loadPath);
da.Fill(dt);
csvTable.DataSource = dt;
Any help is appreciated.