可能重复:
IErrorInfo.GetDescription failed with E_FAIL(0x80004005).System.Data while data adapter Fill()
下面是我必须连接到C#中的Access数据库的代码。连接似乎打开很好(conn.Open()命令没有抛出异常),但是当它到达cmd.ExecuteReader()时,我收到以下错误消息:
“IErrorInfo.GetDescription因E_Fail(0x80004005)而失败。”
我已经检查并仔细检查以确保我正试图从中拉出的表格上的拼写是正确的。
System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft Office 12.0 Access Database Engine OLE DB Provider;" +
@"Data source= C:\Users\nearod\Desktop\ImportDB.accdb";
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM SQL ID Test Load", conn);
OleDbDataReader reader = cmd.ExecuteReader();
// Insert code to process data.
}
catch (Exception ex)
{
MessageBox.Show("Failed to connect to data source");
}
finally
{
conn.Close();
}
答案 0 :(得分:1)
尝试更改
OleDbCommand cmd = new OleDbCommand("SELECT * FROM SQL ID Test Load", conn);
要
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [SQL ID Test Load]", conn);