views:

136

answers:

1

I'm currently working on updating an ms access database by using this code: the error is: System.Windows.Forms.MouseEventArgs

I don't know what is it, can you help me solve my problem, adding, deleting, listing, searching for records is already working. If I can finish this update then I can proceed with the system that we are doing for a company for our school project

Try
    If MessageBox.Show("Save and update database?", _
    "Confirmation", MessageBoxButtons.YesNo) = _
    Windows.Forms.DialogResult.Yes Then
        Dim idXs As Integer
        Dim dSet As New DataSet
        Dim conn As New OleDb.OleDbConnection
        Dim strSQL As String

        conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\ACCESS DATABASE\search.mdb"
        conn.Open()

        strSQL = "Select * From GH"
        Dim da As OleDbDataAdapter
        da = New OleDb.OleDbDataAdapter(strSQL, conn)
        da.Fill(dSet, "GH") 'fill dataset

        'code for editing records
        Dim cb As New OleDbCommandBuilder(da)
        idXs = Form1.idX 'retrieve index from Form1
        dSet.Tables("GH").Rows(idXs).Item(0) = TextBox1.Text
        dSet.Tables("GH").Rows(idXs).Item(1) = TextBox2.Text
        dSet.Tables("GH").Rows(idXs).Item(2) = TextBox3.Text
        dSet.Tables("GH").Rows(idXs).Item(3) = TextBox4.Text
        da.Update(dSet, "GH") 'update database

        conn.Close() 'close connection
        reloadMyMain() 'show new changes in form1 if any
    Else
        DSET.RejectChanges() 'cancel delete
    End If
Catch ex As Exception
    MsgBox(e.ToString) 'show exception message
End Try

TextBox1.ReadOnly = True
TextBox2.ReadOnly = True
TextBox3.ReadOnly = True
TextBox4.ReadOnly = True

Button2.Text = "Edit"
Me.Close() 'close form2
+2  A: 

mouseEventArgs means that you're probably trying to do this on some mouse event. The code you gave us is not related to problem you're describing.

Could you send the whole exception you're getting and the entire code for the method where this code is executed from.

Fedor Hajdu