dataset changes not reflectin in database

D

divya jain

Hi,

i have a data adapter(da) with ther query "select product, qty form
order"

and a dataset with the name (ds)

da.fill(ds,"aa")

//i want to update only this particular column of this dataset, so i m
using:

dim d as DataGrid1.Dataitem


ds.tables("aa").row(0).item("Qty") = Ctype(D.FindControl("TxtQty"),
TextBox).Text

//this code is working fine but these changes are reflectin only in the
daset how can i make these changes in the datasource.

how can i use commandbuilder to make changes in the database also i dont
have any primary key in my "order table"
 
G

Guest

Hi Divya,

If only your data is from single database table, you can use
SqlCommandBuilder to auto-generate update command for SqlDataAdapter.

Following code snippet demonstrates SqlDataAdapter update backend database:

Dim da As New SqlDataAdapter(sql_query_from_single_table, connection_string);
Dim builder As New SqlCommandBuilder(dap)
Dim ds As New DataSet
da.Fill(ds, "aa")
Dim row_index As Integer = ?
Dim Qty As Integer =
Convert.ToInt32(CType(DataGrid1.Items(row_index).FindControl("TxtQty"),
TextBox).Text)
ds.Tables("aa").Rows(row_index)("Qty") = Qty
da.Update(ds)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top