Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...