G
Guest
Hello All:
I am importing an Excel / CSV file. The problem I am having is: the
columns are being defined for me as int32 (able to determine by using the
..GetFieldType method). As a result: when a row has a character, we are
losing this data, because it is being interprested as "". How would I go
about making the columns always text? Below is my code that I am using:
System.Data.OleDb.OleDbConnection con = new
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + System.IO.Path.GetDirectoryName(fileName) + ";Extended
Properties=\"text;HDR=Yes;IMEX=1;FMT=Delimited\"");
System.Data.OleDb.OleDbCommand command = new
System.Data.OleDb.OleDbCommand("Select * from " +
System.IO.Path.GetFileName(fileName), con);
con.Open();
System.Data.IDataReader dr = command.ExecuteReader();
while (dr.Read())
{
if(dr[0].ToString()!="")
if(!CSVvalues.ContainsKey(dr[0].ToString()))
CSVvalues.Add(dr[0].ToString(), dr[1].ToString());
}
I am importing an Excel / CSV file. The problem I am having is: the
columns are being defined for me as int32 (able to determine by using the
..GetFieldType method). As a result: when a row has a character, we are
losing this data, because it is being interprested as "". How would I go
about making the columns always text? Below is my code that I am using:
System.Data.OleDb.OleDbConnection con = new
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + System.IO.Path.GetDirectoryName(fileName) + ";Extended
Properties=\"text;HDR=Yes;IMEX=1;FMT=Delimited\"");
System.Data.OleDb.OleDbCommand command = new
System.Data.OleDb.OleDbCommand("Select * from " +
System.IO.Path.GetFileName(fileName), con);
con.Open();
System.Data.IDataReader dr = command.ExecuteReader();
while (dr.Read())
{
if(dr[0].ToString()!="")
if(!CSVvalues.ContainsKey(dr[0].ToString()))
CSVvalues.Add(dr[0].ToString(), dr[1].ToString());
}