mcerk Posted December 12, 2004 Posted December 12, 2004 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. 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 Quote
mcerk Posted December 12, 2004 Author Posted December 12, 2004 I figured it out, and I am posting it for other newbies. 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) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.