ERROR:Make sure that it does not include invalid characters or punctuation and that it is not too long
ERROR:Make sure that it does not include invalid characters or punctuation and that it is not too long
我尝试使用 oledb 获取 excel sheet 个名称。
我的连接字符串是:
string ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
其中文件路径是文件名。
我的代码:
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [Employee$]", conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(Data);
在这一行出现错误
adapter.Fill(Data);
错误是
'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: 'Employee$' is not a valid name. Make sure
that it does not include invalid characters or punctuation and that it
is not too long.
如何做到这一点?
试试这个:
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [dataGridView1_Data$]", conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(Data);
我尝试使用 oledb 获取 excel sheet 个名称。
我的连接字符串是:
string ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
其中文件路径是文件名。
我的代码:
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [Employee$]", conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(Data);
在这一行出现错误
adapter.Fill(Data);
错误是
'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: 'Employee$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
如何做到这一点?
试试这个:
OleDbCommand cmd = new OleDbCommand(@"SELECT * FROM [dataGridView1_Data$]", conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(Data);