DatasetTableAdapters.CustomerDataAdapter customerData = new DatasetTableAdapters.CustomerDataAdapter();
customerData.insertQuery("Value1", "Value");
記錄未插入數據庫爲什麼?我正在使用數據集設計器。使用DataAdapter插入記錄
DatasetTableAdapters.CustomerDataAdapter customerData = new DatasetTableAdapters.CustomerDataAdapter();
customerData.insertQuery("Value1", "Value");
記錄未插入數據庫爲什麼?我正在使用數據集設計器。使用DataAdapter插入記錄
嘗試這樣的事情可能?
DatasetTableAdapters.CustomerDataAdapter customerData = new DatasetTableAdapters.CustomerDataAdapter();
//make instance of the applicable customerDataTable here
customerData.Fill(customerDataTable);
customerDataTable.Rows.Add("Value1", "Value");//<-you could also add the values directly to your dataset here instead of the datatable
customerData.Update(customerDataTable);
我在winforms應用程序中使用此方法。也許你可以編輯它以適應您的需求?
嘗試在表適配器上使用.Insert
方法。
http://msdn.microsoft.com/en-us/library/ms233812(v=vs.80).aspx
而不是.Update方法,你可以嘗試使用你的.insertQuery,看看是否也可以。但是因爲新行被添加到數據表中,所以更新會自動插入,因爲它不會編輯dataTable中的一行。 –