Results 1 to 2 of 2

Thread: Error when committing the row to the original data store

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    154

    Error when committing the row to the original data store

    Hey Everyone...

    .....error when committing the row to the original data store.....

    I sometimes get this error after I delete a record from my invoice form.. It doesn't do it all the time.

    But it doesn't seem to actually throw this error until I mouse_move over the datagrid column headers of my datagrid..

    The following is my delete code for my invoice form...

    [CODE=vb]
    If (e.KeyCode()) = System.Windows.Forms.Keys.Delete And e.Shift = True Then
    Try
    Dim CurrentCellItem As String = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0)
    Dim bookmark2 As String
    bookmark2 = CurrentCellItem.TrimEnd(" ")
    If vbYes = MsgBox("Are You Sure You Want To Delete This Part Number? " & Chr(13) & "***" & bookmark2 & "***", MsgBoxStyle.YesNo, "Delete Record Confirmation") Then
    mSql = "DELETE FROM Invoices WHERE (INV_ITEM = '" & bookmark2 & "' AND INV_NUMBER = '" & Label6.Text & "')"

    Dim sqlcommand As New SqlCommand(mSql, PolarisConnection)
    sqlcommand.Connection.Open()

    Try
    sqlcommand.ExecuteNonQuery()
    Catch ex As Exception
    MessageBox.Show(ex.StackTrace)
    End Try
    sqlcommand.Connection.Close()

    Try
    mPartsNumber.Clear()
    mSql = "Select top 100 INV_ITEM, INV_DISC, INV_LIST, INV_STCK, INV_BO, INV_AMOUNT From Invoices WHERE INV_NUMBER = '" & Label6.Text & "'"

    mDa = New SqlClient.SqlDataAdapter(mSql, PolarisConnection)
    mDa.Fill(PartsNumberData.Tables("mPartsNumber"))
    mDa = Nothing

    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try

    Label50.Text = vbNullString
    Label51.Text = vbNullString
    Label53.Text = vbNullString
    Label54.Text = vbNullString

    Dim dr As DataRow
    Dim decSum As Decimal

    For Each dr In PartsNumberData.Tables(0).Rows
    decSum += Convert.ToDecimal((dr.Item("INV_AMOUNT")))
    Next

    Label50.Text = (decSum)
    Label51.Text = Convert.ToString(Label50.Text * 7 / 100)
    Label53.Text = Convert.ToString(Label50.Text * 8 / 100)
    Label54.Text = Val(Label50.Text) + Val(Label51.Text) + Val(Label53.Text)

    Label54.Text = Format(Label54.Text, "Currency")
    Label50.Text = Format(Label50.Text, "Currency")
    Label51.Text = Format(Label51.Text, "Currency")
    Label53.Text = Format(Label53.Text, "Currency")

    Label50.Text = Label50.Text.TrimStart("$")
    Label51.Text = Label51.Text.TrimStart("$")
    Label53.Text = Label53.Text.TrimStart("$")

    Else
    End If
    Catch ex As Exception
    MsgBox("There Are No Part's To Delete From This Invoice! ", MsgBoxStyle.Information, "Delete Record Confirmation")
    End Try

    [/CODE]

    The following is my Mouse_move for the datagrid in my invoice form..

    [CODE=vb]
    Private Sub DataGrid1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseMove
    Dim pt = New Point(e.X, e.Y)
    Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt)


    If hti.Type = DataGrid.HitTestType.Cell Then
    DataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)

    Dim current As Integer
    For current = 0 To PartsNumberData.Tables(0).Rows.Count - 1
    Try
    If DataGrid1.IsSelected(current) Then
    DataGrid1.UnSelect(current)
    Else
    End If
    Catch ex As Exception
    End Try
    Next current
    DataGrid1.Select(hti.Row)

    End If
    End Sub
    [/CODE]

    I put a test in the above code to determine if it was a column header and it still gave me the error.

    I've attached a screenshot of the error.

    Thanks for the help in Advance!!
    Attached Images Attached Images  

  2. #2
    New Member
    Join Date
    Aug 2006
    Posts
    1

    Re: Error when committing the row to the original data store

    Hello Neumee
    If you are using any costom classes that inherits DataGridTextBoxColumns class ...

    then you must comment following two methods of that class

    1) protected overrides function commit(...)

    end function

    2) protected overloads overrides sub edit(...)

    end sub

    where you are passing your datasource as a currencymanager as an argument.

    hope this will help
    I also had got the same error but doing as aforesaid overcome the error.

    Thanks
    Ninad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width