Can anybody point me the correct direction in deleting rows in a datagrid? I've tried searching on msdn and even here on the forum but I still haven't found anything. This is the current code I have:
Code:Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim strRoll2 As String ' strRoll2 holds the Delete Query strRoll2 = "Delete from Param2 where ParamSetName = @ParamSetName And " _ & "Reservoir = @Reservoir And Description = @Description " Dim DaRoll As New OleDb.OleDbDataAdapter(strRoll2, gConn) DaRoll.DeleteCommand = New OleDbCommand(strRoll2, gConn) Dim rollBack As New OleDbParameter rollBack = DaRoll.DeleteCommand.Parameters.Add("@ParamSetName", OleDbType.VarChar) rollBack.SourceColumn = "ParamSetName" rollBack.SourceVersion = DataRowVersion.Original rollBack = DaRoll.DeleteCommand.Parameters.Add("@Reservoir", OleDbType.VarChar) rollBack.SourceColumn = "Reservoir" rollBack.SourceVersion = DataRowVersion.Current rollBack = DaRoll.DeleteCommand.Parameters.Add("@Description", OleDbType.VarChar) rollBack.SourceColumn = "Description" rollBack.SourceVersion = DataRowVersion.Current Dim row As DataRowCollection = dsPar.Tables(0).Rows ' If the delete is not successful then the Catch will be executed Try DaRoll.Update(dsPar) Catch x As Exception ' The error will be displayed in a messagebox MsgBox(x.Message) End Try DaRoll.Dispose() Me.FillDgDelete() End Sub




Reply With Quote