B
bluewind44
Hello, I made a page that used for import data from .xls files.
At this page, users upload the .xls file to the server, then the app
uses an OleDB connection and the Jet provider to read the data using
the OleDB DataAdapter, then I bind it to a datagrid.
It works fine, but occationally some data is missing on a datagrid,
especially number datas.
Is anyone have same problem? or Is anyone can help me out?
--------
Here's the code that i am using.
DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sFileName +
";Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=0;\"";
objOleCon = new OleDbConnection(DSN);
objOleCon.Open();
dtResult = objOleCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
object[]{null,null,null,"TABLE"});
objOleCon.Close();
if (dtResult.Rows.Count>0)
{
string[] sSheet = new string[dtResult.Rows.Count];
dsExcelDataSet = new DataSet();
dsExcel = new DataSet();
ExcelData = new OleDbDataAdapter("SELECT * FROM
["+dtResult.Rows[0]["TABLE_NAME"].ToString()+"]" , objOleCon);
ExcelData.Fill(dsExcel);
dtExcelData = dsExcel.Tables[0];
}
-----------
At this page, users upload the .xls file to the server, then the app
uses an OleDB connection and the Jet provider to read the data using
the OleDB DataAdapter, then I bind it to a datagrid.
It works fine, but occationally some data is missing on a datagrid,
especially number datas.
Is anyone have same problem? or Is anyone can help me out?
--------
Here's the code that i am using.
DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sFileName +
";Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=0;\"";
objOleCon = new OleDbConnection(DSN);
objOleCon.Open();
dtResult = objOleCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new
object[]{null,null,null,"TABLE"});
objOleCon.Close();
if (dtResult.Rows.Count>0)
{
string[] sSheet = new string[dtResult.Rows.Count];
dsExcelDataSet = new DataSet();
dsExcel = new DataSet();
ExcelData = new OleDbDataAdapter("SELECT * FROM
["+dtResult.Rows[0]["TABLE_NAME"].ToString()+"]" , objOleCon);
ExcelData.Fill(dsExcel);
dtExcelData = dsExcel.Tables[0];
}
-----------