Home All Groups Group Topic Archive Search About

dataset changes not reflectin in database

Author
22 Jan 2006 10:06 AM
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"


*** Sent via Developersdex http://www.developersdex.com ***

Author
22 Jan 2006 3:50 PM
Elton W
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


Show quote
"divya jain" wrote:

>
> 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"
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

AddThis Social Bookmark Button