hi all,
i think i'm beginning to understand how the dataadapter.update method is being used here in ado.net... but i need some verifications first.
here's is my scenario..
at form load, i retrieve data from my database using of course, a connection, an adapter, and a dataset.
sample source:
here is a sample screen after form loaded and data was binded to my datagrid.
then, i try to edit some data in my datagrid like this...
then i put this code in a save button for example.
now, based on the steps i have here, if i click the save button, will it update the changes made to my database so the next time the form loads, it will display records equal to that of the second screen?
i just want to clarify, based on the images, i changed data on 2 rows... will my update command automatically update both rows for me or do i need to do something else?
thanks...
i think i'm beginning to understand how the dataadapter.update method is being used here in ado.net... but i need some verifications first.
here's is my scenario..
at form load, i retrieve data from my database using of course, a connection, an adapter, and a dataset.
sample source:
VB.NET:
Dim connection As New SqlConnection("connection string here")
Dim adapter As New SqlDataAdapter("SELECT ID, username, password FROM accounts", connection)
Dim update As New SqlCommand("UPDATE accounts SET username = @username, password = @password WHERE ID = @ID", connection)
update.Parameters.Add("@id", SqlDbType.Int, 4, "id")
update.Parameters.Add("@username", SqlDbType.VarChar, 15, "username")
update.Parameters.Add("@password", SqlDbType.VarChar, 15, "password")
adapter.UpdateCommand = update
dim mydataset as new dataset
adapter.fill(mydataset, "accounts")
datagrid.datasource = mydataset
here is a sample screen after form loaded and data was binded to my datagrid.
then, i try to edit some data in my datagrid like this...
then i put this code in a save button for example.
VB.NET:
adapter.Update(mydataset, "accounts")
now, based on the steps i have here, if i click the save button, will it update the changes made to my database so the next time the form loads, it will display records equal to that of the second screen?
i just want to clarify, based on the images, i changed data on 2 rows... will my update command automatically update both rows for me or do i need to do something else?
thanks...
Last edited: