开发者

Inserting record using DataAdapter

开发者 https://www.devze.com 2023-03-20 18:21 出处:网络
DatasetTableAdapters.CustomerDataAdapter customerData = new DatasetTableAdapters.CustomerDataAdapter();
DatasetTableAdapters.CustomerDataAdapter customerData = new DatasetTableAdapters.CustomerDataAdapter();

customerData.insertQuery("Value1", "Value");
开发者_高级运维

The record is not being inserted into the Database Why? I am using Dataset Designer.


Try something like this maybe?

    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);

I am using this method in a winforms app. Maybe you could just edit it to suit your needs as applicable?


Try using the .Insert method on the table adaptor instead.

http://msdn.microsoft.com/en-us/library/ms233812(v=vs.80).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消