this postと同じエラーが多かれ少なかれありますが、その解決策は私の問題を解決していません。C#でExcelから読み込み中にエラーが発生しました: "...オブジェクトが見つかりませんでした..."
私が取得エラーメッセージ:
The Microsoft Office Access database engine could not find the object 'Adresser$'. Make sure the object exists and that you spell its name and the path name correctly.
は、私がチェックし、ダブルチェックの名前が正しい、私はシートの名前を変更したと、コピー&ペーストの名前を自分のコードの中にいることが、何も動いていないようにみえてきました。何が間違っているのですか?
これは私のコードです:
string conStr = String.Format(
@"Provider={0};Data Source=""{1}"";Extended Properties=""{2}""",
"Microsoft.ACE.OLEDB.12.0",
"REGISTER 090310.xls",
"Excel 12.0 Xml;IMEX=1;HDR=YES;");
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
using (IDbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = conStr;
using (IDbCommand command = connection.CreateCommand())
{
command.CommandText = "SELECT TOP 10 * FROM [Adresser$]";
connection.Open();
// The exception is thrown on this line, with yellow highlight on
// IDataReader dr = command.ExecuteReader()
using (IDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
Console.WriteLine(
string.Format("First name: {0}\tLast name: {1}",
dr[0].ToString(),
dr[1].ToString()));
}
}
}
}
もしもAddresser $になるはずです。二人? – Crispy
いいえ - スウェーデン語では1つだけの綴りです...;) –