in form load ' Call Load Dataset to fill Grid Me.LoadDataSet()I use click Button2 to try to modify a record:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim xxx As String = "Update MyTable01 Set Kode = '00001' Where Kode = '11'" SqlConnection1.Open() SqlDataAdapter1.SelectCommand.CommandText = xxx SqlDataAdapter1.SelectCommand.CommandType = CommandType.Text SqlDataAdapter1.SelectCommand.ExecuteNonQuery() SqlConnection1.Close() UpdateDataSet() End Sub Public Sub UpdateDataSet() Dim objDataSetChanges As WindowsApplication1.DataSet1 = New WindowsApplication1.DataSet1() 'Stop any current edits. Me.BindingContext(objmyds, "MyTable01").EndCurrentEdit() 'Get the changes that have been made to the main dataset. objDataSetChanges = CType(objmyds.GetChanges, WindowsApplication1.DataSet1) 'Check to see if any changes have been made. If (Not (objDataSetChanges) Is Nothing) Then Try 'There are changes that need to be made, so attempt to update the datasource by 'calling the update method and passing the dataset and any parameters. Me.UpdateDataSource(objDataSetChanges) objmyds.Merge(objDataSetChanges) objmyds.AcceptChanges() Catch eUpdate As System.Exception 'Add your error handling code here. Throw eUpdate End Try 'Add your code to check the returned dataset for any errors that may have been 'pushed into the row object's error. End If End Sub Public Sub UpdateDataSource(ByVal ChangedRows As WindowsApplication1.DataSet1) Try 'The data source only needs to be updated if there are changes pending. If (Not (ChangedRows) Is Nothing) Then 'Open the connection. Me.SqlConnection1.Open() 'Attempt to update the data source. Me.SqlDataAdapter1.Update(ChangedRows) End If Catch updateException As System.Exception 'Add your error handling code here. Throw updateException Finally 'Close the connection whether or not the exception was thrown. Me.SqlConnection1.Close() End Try End Sub Public Sub LoadDataSet() 'Create a new dataset to hold the records returned from the call to FillDataSet. 'A temporary dataset is used because filling the existing dataset would 'require the databindings to be rebound. Dim objDataSetTemp As WindowsApplication1.DataSet1 objDataSetTemp = New WindowsApplication1.DataSet1() Try 'Attempt to fill the temporary dataset. Me.FillDataSet(objDataSetTemp) Catch eFillDataSet As System.Exception 'Add your error handling code here. Throw eFillDataSet End Try Try 'Empty the old records from the dataset. objmyds.Clear() 'Merge the records into the main dataset. objmyds.Merge(objDataSetTemp) Catch eLoadMerge As System.Exception 'Add your error handling code here. Throw eLoadMerge End Try End Subanybody can help me? .. many thanks in advance