I'm having an issue with Visual Studio 2010 picking incorrect/inconsistent DataType for the columns when using the OleDbDataAdapter.
Is it possible to focus the Data Type of each column to be string?
Currently i'm trying to convert my CSV file into a Datatable. Some of the columns end up being double when i tried to use the same method on the same column names it turns out to be string (because the 2nd CSV file starts off with a '-' sign so it just assumes it's a string)
using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(filePath) + ";Extended Properties=\"Text;HDR=Yes;TypeGuessRows=0;ImportMixedTypes=Text\""))
using (OleDbCommand command = new OleDbCommand(@"SELECT * FROM [" + Path.GetFileName(filePath) + "]", connection))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
adapter.Fill(dt);
trying to merge it with another csv file:
using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(part2FilePath) + ";Extended Properties=\"Text;HDR=Yes;TypeGuessRows=0;ImportMixedTypes=Text\""))
using (OleDbCommand command = new OleDbCommand(@"SELECT * FROM [" + Path.GetFileName(part2FilePath) + "]", connection))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
DataTable tmpDt = new DataTable();
adapter.Fill(tmpDt);
dt.Merge(tmpDt, true, MissingSchemaAction.Add);
}
I run into this conflict that the data Type does not match. the first CSV has double as one of the column but the same column in the 2nd CSV it is coming up as string.
If possible i'd love to focus all of them to be string and i'll convert them on the fly.
Thanks.