Microsoft Office Access数据库引擎找不到对象'Sheet1 $'。确保对象存在,并且您正确拼写其名称和路径名称。 [英] The Microsoft Office Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
本文介绍了Microsoft Office Access数据库引擎找不到对象'Sheet1 $'。确保对象存在,并且您正确拼写其名称和路径名称。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我试图将表格数据从excel插入到sql server但面临以下问题..
Microsoft Office Access数据库引擎找不到对象'Sheet1 $'。确保对象存在,并正确拼写其名称和路径名。
行 68 : OleDbCommand oledbcmd = new OleDbCommand(exceldataquery,oledb);
Line 69 :oledb.Open();
行 70 :OleDbDataReader dr = oledbcmd.ExecuteReader();
行 71 :SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
行 72 :bulkcopy.DestinationTableName = sqltable;
我的代码
受保护 < span class =code-keyword> void importdatafromexcel( string filepath)
{
string sqltable = PFDummyExcel;
string exceldataquery = 选择EmployeeId,EmployeeName ,金额来自[Sheet1 $];
string excelconnectionstring = @ Provider = Microsoft .ACE.OLEDB.12.0;数据源= + filepath + ;扩展属性= Excel 12.0;坚持安全信息=错误;
string sqlconnectionstring = System.Configuration.ConfigurationManager.ConnectionStrings [ HRGold跨度>]的ConnectionString。
SqlConnection con = new SqlConnection(sqlconnectionstring);
OleDbConnection oledb = new OleDbConnection(excelconnectionstring);
OleDbCommand oledbcmd = new OleDbCommand(exceldataquery,oledb);
oledb.Open();
OleDbDataReader dr = oledbcmd.ExecuteReader();
SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
bulkcopy.DestinationTableName = sqltable;
while (dr.Read())
{
bulkcopy.WriteToServer(dr);
}
oledb.Close();
}
请告诉我如何解决这个问题..
解决方案
'。确保对象存在,并正确拼写其名称和路径名。
行 68 : OleDbCommand oledbcmd = new OleDbCommand(exceldataquery,oledb);
Line 69 :oledb.Open();
行 70 :OleDbDataReader dr = oledbcmd.ExecuteReader();
行 71 :SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
行 72 :bulkcopy.DestinationTableName = sqltable;
我的代码
受保护 < span class =code-keyword> void importdatafromexcel( string filepath)
{
string sqltable = PFDummyExcel;
string exceldataquery = 选择EmployeeId,EmployeeName ,金额来自[Sheet1
;
string excelconnectionstring = @ Provider = Microsoft .ACE.OLEDB.12.0;数据源= + filepath + ;扩展属性= Excel 12.0;坚持安全信息=错误;
string sqlconnectionstring = System.Configuration.ConfigurationManager.ConnectionStrings [ HRGold跨度>]的ConnectionString。
SqlConnection con = new SqlConnection(sqlconnectionstring);
OleDbConnection oledb = new OleDbConnection(excelconnectionstring);
OleDbCommand oledbcmd = new OleDbCommand(exceldataquery,oledb);
oledb.Open();
OleDbDataReader dr = oledbcmd.ExecuteReader();
SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
bulkcopy.DestinationTableName = sqltable;
while (dr.Read())
{
bulkcopy.WriteToServer(dr);
}
oledb.Close();
}
请告诉我如何解决这个问题..
您能否验证以下链接:
http://www.codeproject.com/Tips/636719/Import-MS-Excel-data-to- SQL-Server-table-using-Csh
http://www.aspdotnet-suresh.com/2012/12/c-importupload-data-from-excel-to-sql.html [< a href =http://www.aspdotnet-suresh.com/2012/12/c-importupload-data-from-excel-to-sql.html\"target =_ blanktitle =New Window> ^
Hello,
I am trying to insert an table data from excel to sql server but facing the following problem..
The Microsoft Office Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
Line 68: OleDbCommand oledbcmd = new OleDbCommand(exceldataquery, oledb);
Line 69: oledb.Open();
Line 70: OleDbDataReader dr = oledbcmd.ExecuteReader();
Line 71: SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
Line 72: bulkcopy.DestinationTableName = sqltable;
My Code
protected void importdatafromexcel(string filepath)
{
string sqltable = "PFDummyExcel";
string exceldataquery = "select EmployeeId,EmployeeName,Amount from [Sheet1$]";
string excelconnectionstring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties=Excel 12.0;Persist Security Info=False";
string sqlconnectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["HRGold"].ConnectionString;
SqlConnection con = new SqlConnection(sqlconnectionstring);
OleDbConnection oledb = new OleDbConnection(excelconnectionstring);
OleDbCommand oledbcmd = new OleDbCommand(exceldataquery, oledb);
oledb.Open();
OleDbDataReader dr = oledbcmd.ExecuteReader();
SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring);
bulkcopy.DestinationTableName = sqltable;
while (dr.Read())
{
bulkcopy.WriteToServer(dr);
}
oledb.Close();
}
Please tell me how will i solve this..
解决方案
'. Make sure the object exists and that you spell its name and the path name correctly.
Line 68: OleDbCommand oledbcmd = new OleDbCommand(exceldataquery, oledb); Line 69: oledb.Open(); Line 70: OleDbDataReader dr = oledbcmd.ExecuteReader(); Line 71: SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring); Line 72: bulkcopy.DestinationTableName = sqltable;
My Code
protected void importdatafromexcel(string filepath) { string sqltable = "PFDummyExcel"; string exceldataquery = "select EmployeeId,EmployeeName,Amount from [Sheet1
"; string excelconnectionstring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties=Excel 12.0;Persist Security Info=False"; string sqlconnectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["HRGold"].ConnectionString; SqlConnection con = new SqlConnection(sqlconnectionstring); OleDbConnection oledb = new OleDbConnection(excelconnectionstring); OleDbCommand oledbcmd = new OleDbCommand(exceldataquery, oledb); oledb.Open(); OleDbDataReader dr = oledbcmd.ExecuteReader(); SqlBulkCopy bulkcopy = new SqlBulkCopy(sqlconnectionstring); bulkcopy.DestinationTableName = sqltable; while (dr.Read()) { bulkcopy.WriteToServer(dr); } oledb.Close(); }
Please tell me how will i solve this..
Can you verify the below links:
http://www.codeproject.com/Tips/636719/Import-MS-Excel-data-to-SQL-Server-table-using-Csh
http://www.aspdotnet-suresh.com/2012/12/c-importupload-data-from-excel-to-sql.html[^]
这篇关于Microsoft Office Access数据库引擎找不到对象'Sheet1 $'。确保对象存在,并且您正确拼写其名称和路径名称。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文