string P_str_Con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePathmdb ;
string P_str_Sql = "";
OleDbConnection oledbcon = new OleDbConnection(P_str_Con);
oledbcon.Open();
//向Excel工作表导入数据
OleDbCommand oledbcom;
P_str_Sql =@"select * into[Excel 8.0;database="+ filePathexcel + "]."+"["+"Table3"+"]from"+ "Table3"+"";
oledbcom = new System.Data.OleDb.OleDbCommand(P_str_Sql, oledbcon);
oledbcom.ExecuteNonQuery();
oledbcon.Close();
oledbcon.Dispose();
MessageBox.Show("导入成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
把access数据导入指定excel
,oledbcom.ExecuteNonQuery();出错为:System.Data.OleDbException:查询输入必须包含至少一个表或查询。
我打开的数据库是有表Table3的。
是因为打开的excel是xlsx而不是xls的么,如果是的话怎么打开xlsx