updating the dataset in grid

gurunathan

New member
Joined
Dec 7, 2005
Messages
2
Programming Experience
Beginner
hi
i need to know the procs for updating the dataset ....in turn these changes should affect the db ....the dataset is being loaded in the datagrid ....use dataadapter to make changes ..

kindly reply
guru
 
Code generated by Form Wizard

Here is code very similar to what is generated by the form wizard:

this calls the update:

VB.NET:
        Try
            Me.UpdateDataSet()
        Catch eUpdate As System.Exception
            System.Windows.Forms.MessageBox.Show(eUpdate.Message)
        End Try

Here is the code to update the dataset:

VB.NET:
    Public Sub UpdateDataSet()
        Dim datasetChanges As DataSet1 = New DataSet1
        Me.BindingContext(DataSet11, "Table Name").EndCurrentEdit()
        datasetChanges = CType(DataSet11.GetChanges, DataSet1)
        If (Not (datasetChanges) Is Nothing) Then
            Try
                Me.UpdateDataSource(datasetChanges)
                DataSet11.AcceptChanges()
            Catch eUpdate As System.Exception
                Throw eUpdate
            End Try
        End If
    End Sub

    Public Sub UpdateDataSource(ByVal ChangedRows As DataSet1)
        Try
            If (Not (ChangedRows) Is Nothing) Then
                Me.SqlConnection1.Open()
                SqlDataAdapter1.Update(ChangedRows)
            End If
        Catch updateException As System.Exception
            Throw updateException
        Finally
            Me.SqlConnection1.Close()
        End Try
    End Sub

Hope this helps...
 
Back
Top