有谁可以告诉我为什么以下代码不会将数据提交到访问数据库表?
如果我查看dtAccess数据表,它会正确显示我想要写入Access的内容,但是当我进入Access并查看表时,没有任何内容被写入。
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"C:\\Database.accdb\";Persist Security Info=False;");
string queryString = "SELECT * from " + lblTable.Text;
//OleDbDataAdapter adapter = new OleDbDataAdapter(queryString, myConnection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
DataTable dtAccess = new DataTable();
DataTable dtCSV = new DataTable();
dtCSV = ds.Tables[0];
// OleDbCommand cmd = new OleDbCommand("INSERT INTO " + lblTable.Text + "(ASIN) VALUES (1234)", myConnection); //this command works when used with cmd.executenonquery();
adapter.SelectCommand = new OleDbCommand("SELECT * from " + lblTable.Text, myConnection);
adapter.InsertCommand = new OleDbCommand("INSERT INTO " + lblTable.Text + " ([ASIN], [MAP Retail], [Style Number], [MSRP Retail]) VALUES (?,?,?,?)", myConnection);
myConnection.Open();
adapter.Fill(dtAccess);
dtAccess.Merge(dtCSV);
adapter.Update(dtAccess);
myConnection.Close();