我做进口从Excel工作表到SQL database..everything数据是好的,当我运行这段代码,我访问引擎找不到MT票据,它会引发这样的错误.. 我的错误是它为什么会抛出这样的错误?
Microsoft Jet数据库引擎找不到对象'Sheet1 $'。确保对象存在,并且正确拼写其名称和路径名。
,但我已经与我的指定文件夹中检查,其correct..then我不知道为什么它重复
低于我的C#代码..
public partial class _Default : System.Web.UI.Page
{
string constr = @"Data Source=VIS1-B12\SQLEXPRESS;Initial Catalog=Sql_Excel;Integrated Security=True providerName=System.Data.SqlClient" ;
protected void btn_okClick(object sender, EventArgs e)
{
string path = Fup_Excel.PostedFile.FileName;
string exconstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+";Extended Properties=Excel 8.0";
OleDbConnection excelcon = new OleDbConnection(exconstr);
excelcon.Open();
OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]", excelcon);
OleDbDataReader dbreader;
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
//dap.Fill(ds,"sheet1");
dbreader = cmd.ExecuteReader();
SqlBulkCopy bcpy = new SqlBulkCopy(constr);
bcpy.DestinationTableName = "Excel_Details";
bcpy.WriteToServer(dbreader);
//GridView1.DataSource = ds.Tables[0].DefaultView;
//GridView1.DataBind();
excelcon.Close();
}
}
打开* *的Excel文件和验证片的名称。重要的是,您必须在开始阅读之前复制上传的文件。 – adatapost
表名是-Sheet1 – Ananth
不,我用正确的文件检查只有 – Ananth