update data from datagrid using ado in vb.net
-
i am using vb.net with sql2000 ihave used adodb.connection and adodb.recordset then i have used a dataadapter and dataset to show resords in datagrid now i want to update changes made to the data in the datagrid can any one help me
bhaskar varma
-
i am using vb.net with sql2000 ihave used adodb.connection and adodb.recordset then i have used a dataadapter and dataset to show resords in datagrid now i want to update changes made to the data in the datagrid can any one help me
bhaskar varma
can be easily found in the MSDN! everything can be done by using the DataAdapter. example from MSDN: ' Assumes connection is a valid SqlConnection. Dim adapter As SqlDataAdapter = New SqlDataAdapter( _ "SELECT CategoryID, CategoryName FROM Categories", connection) adapter.UpdateCommand = New SqlCommand( _ "UPDATE Categories SET CategoryName = @CategoryName " & _ "WHERE CategoryID = @CategoryID", connection) adapter.UpdateCommand.Parameters.Add( _ "@CategoryName", SqlDbType.NVarChar, 15, "CategoryName") Dim parameter As SqlParameter = adapter.UpdateCommand.Parameters.Add( _ "@CategoryID", SqlDbType.Int) parameter.SourceColumn = "CategoryID" parameter.SourceVersion = DataRowVersion.Original Dim dataSet As DataSet = New DataSet adapter.Fill(dataSet, "Categories") Dim row As DataRow = dataSet.Tables("Categories").Rows(0) row("CategoryName") = "New Category" adapter.Update(dataSet, "Categories") -walter