Updating Dataset and updating dataset to database

mcerk

Well-known member
Joined
Nov 1, 2004
Messages
78
Hi. If I understand correctly, dataset is a copy of database.

So my question is. How can I programatically update Field1 value to dataset, and how can I then update dataset back to database (for example SQL).

For example:
I have Textbox1, Button1, Button2 and DataGrid1 on Form1.
Textbox1 is not bound to dataset, but Datagrid is.

I know how to make a connection to database and how to fill dataset.

Code:
DataAdapter.Fill(DataSet) now data is copied from database to dataset, and datagrid displays this data
Textbox1.text = "Some Text"

so, how can I do next:
when I press Button1 textbox1.text is updated to Field1 in dataset (but not to database) and I want that DataGrid would display new value.

when I press Button2, the whole DataSet is updated back to database


tx a lot
 
I figured it out, and I am posting it for other newbies.
Code:
DataAdapter.Fill(DataSet) now data is copied from database to dataset, and datagrid displays this data
Textbox1.text = "Some Text"

so, how can I do next : 
when I press Button1 textbox1.text is updated to Field1 in dataset (but not to database) 
Dim NewRow As DataRow
NewRow = DataSet11.Tables("Table1").NewRow
NewRow.Item("Field1")=Me.TextBox1.Text
DataSet11.Tables("Table1").Rows.Add(NewRow)


when I press Button2, the whole DataSet is updated back to database
DataAdapter.Update(DataSet)
 
Back
Top