G
Guest
Hi there,
I load an excel file from an asp.net page and try to read it into a dataset.
The problem is that it tells me: Database or object is read-only
It only needs to be read only. Here is the code. Could someone please advice
me what I am doing wrong. Thank you Chris
(FileExcel is the input field)
System.IO.Stream sio;
sio = FileExcel.PostedFile.InputStream;
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + sio + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]",
objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet dsExcel = new DataSet();
objAdapter1.Fill(dsExcel);
objConn.Close();
I load an excel file from an asp.net page and try to read it into a dataset.
The problem is that it tells me: Database or object is read-only
It only needs to be read only. Here is the code. Could someone please advice
me what I am doing wrong. Thank you Chris
(FileExcel is the input field)
System.IO.Stream sio;
sio = FileExcel.PostedFile.InputStream;
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + sio + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]",
objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet dsExcel = new DataSet();
objAdapter1.Fill(dsExcel);
objConn.Close();