关于EXCEL导入SQL
在一个页面有2个Button1_Click事件。都要运行:
string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + FileUpload1.PostedFile.FileName.ToString() + ";" + "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 objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1);
但总是出错,怎么避免
------解决方案--------------------
请说具体错误,如果是都要运行的话,可以单独设置两个方法,然后在一个Click事件里同时调用
------解决方案--------------------