I
Igor Vukomanovic
Hi,
I'm using ADO.NET and have troubles reading excel formatted data.
leDbDataReader returns DBNull for all the values in the columns in xls
workbook which aren't formatted as "Text"!
I'm using this connection string:
"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = xlsfile;Extended
Properties = Excel 8.0;"
This is the relevant part of the code:
---------
System.Data.OleDb.OleDbConnection excelConn;
System.Data.OleDb.OleDbCommand excelCommand;
System.Data.OleDb.OleDbDataReader excelReader;
object[] values;
excelConn = new System.Data.OleDb.OleDbConnection(excelConnStr);
excelCommand = new System.Data.OleDb.OleDbCommand();
excelConn.Open();
excelCommand.Connection = excelConn;
excelCommand.CommandText = "SELECT * FROM ["+sheetName+"]";
excelReader = excelCommand.ExecuteReader();
while (excelReader.Read())
{
excelReader.GetValues(values);
.....
}
-------------
"values" array is filled correctly with data from all the fields which are
formatted as "Text" in Excel workbook, but all others (I tried Date and
Number) are System.DBNull both in type and in value.
Any ideas ??
Thanks!
I'm using ADO.NET and have troubles reading excel formatted data.
leDbDataReader returns DBNull for all the values in the columns in xls
workbook which aren't formatted as "Text"!
I'm using this connection string:
"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = xlsfile;Extended
Properties = Excel 8.0;"
This is the relevant part of the code:
---------
System.Data.OleDb.OleDbConnection excelConn;
System.Data.OleDb.OleDbCommand excelCommand;
System.Data.OleDb.OleDbDataReader excelReader;
object[] values;
excelConn = new System.Data.OleDb.OleDbConnection(excelConnStr);
excelCommand = new System.Data.OleDb.OleDbCommand();
excelConn.Open();
excelCommand.Connection = excelConn;
excelCommand.CommandText = "SELECT * FROM ["+sheetName+"]";
excelReader = excelCommand.ExecuteReader();
while (excelReader.Read())
{
excelReader.GetValues(values);
.....
}
-------------
"values" array is filled correctly with data from all the fields which are
formatted as "Text" in Excel workbook, but all others (I tried Date and
Number) are System.DBNull both in type and in value.
Any ideas ??
Thanks!