2
SqlDataReader reader;
string r="";
if ((FileUpload1.PostedFile != null)&&(FileUpload1.PostedFile.ContentLength > 0))
{
r = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
}
OleDbConnection oconn =
new OleDbConnection
(@"Provider=Microsoft.Jet.OLEDB.4.0;"
+ @"Data Source="+r+";"
+ @"Extended Properties=""Excel 8.0;HDR=Yes;""");
oconn.Open();
OleDbCommand dbcom = new OleDbCommand("SELECT * FROM [Sheet1$]", oconn);
OleDbDataReader dbreader = dbcom.ExecuteReader();
int rni = dbreader.GetOrdinal ("RollNo");
int mki = dbreader.GetOrdinal ("marks");
這裏程序只有在項目文件夾中存在excel工作表。如果對Excel工作表進行了任何更改,然後程序再次運行,那麼只有之前存在的行被提取,而不是稍後添加的那些。請幫我.....在此先感謝.....問題閱讀excel表