click on modify button?
Public Sub DoModify()
Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember)
===>>> Dim dr As DataRow = CType(bm.Current, DataRowView).Row <<<===
Dim editform As New EditTransOverride(dr)
Dim retval As DialogResult = editform.ShowDialog()
If retval = DialogResult.OK Then
bm.EndCurrentEdit()
Try
Dim substr As String = dr.Item(4)
substr = substr.Substring(0, 2)
ExecOnTransOverride.upd(dr.Item(1), dr.Item(2), dr.Item(3), dr.Item(4), dr.Item(5), dr.Item(6), dr.Item(8), dr.Item(7), DateTime.Now, dr.Item(7), dr.Item(9))
SqlDataAdapter1.Update(ds, "DsTransOverride1")
ds.Tables("DsTransOverride1").AcceptChanges()
MsgBox("Data Inserted Successfully !", MsgBoxStyle.Information, Me.Text)
Catch se As SqlException
MessageBox.Show(se.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
bm.CancelCurrentEdit()
End If
End Sub
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll
Additional information: No value at index -1.
I get an error
===>>> Dim dr As DataRow = CType(bm.Current, DataRowView).Row <<<===
What is going on?
Public Sub DoModify()
Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember)
===>>> Dim dr As DataRow = CType(bm.Current, DataRowView).Row <<<===
Dim editform As New EditTransOverride(dr)
Dim retval As DialogResult = editform.ShowDialog()
If retval = DialogResult.OK Then
bm.EndCurrentEdit()
Try
Dim substr As String = dr.Item(4)
substr = substr.Substring(0, 2)
ExecOnTransOverride.upd(dr.Item(1), dr.Item(2), dr.Item(3), dr.Item(4), dr.Item(5), dr.Item(6), dr.Item(8), dr.Item(7), DateTime.Now, dr.Item(7), dr.Item(9))
SqlDataAdapter1.Update(ds, "DsTransOverride1")
ds.Tables("DsTransOverride1").AcceptChanges()
MsgBox("Data Inserted Successfully !", MsgBoxStyle.Information, Me.Text)
Catch se As SqlException
MessageBox.Show(se.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
bm.CancelCurrentEdit()
End If
End Sub
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll
Additional information: No value at index -1.
I get an error
===>>> Dim dr As DataRow = CType(bm.Current, DataRowView).Row <<<===
What is going on?