ADODB Connection Visual Basic 2008

I´m receiving an error while updating access data base using adodb.
---------------------------------------------------------------------------------------------
AccessConnect2 = "Driver={Microsoft Access Driver (*.mdb)};" & _
                      "Dbq=dados.mdb;" & _
                      "DefaultDir=e:\dados;" & _
                      "Uid=Admin;Pwd=;"
            Conn2.ConnectionString = AccessConnect
            Conn2.Open()

            xmat = Rs1.Fields("Matricula").Value
            Xsql = "Select * from " & TextARQ.Text.ToString & " where MAT=" & CStr(xmat)
            Rs2 = Conn2.Execute(Xsql)

            If Not Rs2.EOF Then

                Rs2.Fields("AT").Value = "S"
                Rs2.Update()  

This update generate an error ..
Jose BredariolPMPAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
baffy2000Connect With a Mentor Commented:
Can you tell us what error you are receiving and at what line it occurs? It's hard to say what the problem might be otherwise. Does the user Admin have a password? You haven't supplied one. Is the field MAT a string field? You haven't put quotes around it in the line:

       Xsql = "Select * from " & TextARQ.Text.ToString & " where MAT=" & CStr(xmat)

(Should this be:)?

        Xsql = "Select * from " & TextARQ.Text.ToString & " where MAT='" & CStr(xmat) & "'"

What's the value of TextARQ.Text.ToString? Is this a valid tablename? Does it contain the field "AT"?
There are all kinds of potential problems here, but it's hard to say what your problem is without an error message.
0
 
Jose BredariolPMPAuthor Commented:
VB error 0
generated by description
-------------------------------------------------------------
The error is on update process. While debugging the update line gos to the Adoerror procedure :
AdoError:
        i = 1
        On Error Resume Next

        ' Enumerate Errors collection and display properties of
        ' each Error object (if Errors Collection is filled out)
        Errs1 = Conn1.Errors
        For Each errLoop In Errs1
            With errLoop
                strTmp = strTmp & vbCrLf & "ADO Error # " & i & ":"
                strTmp = strTmp & vbCrLf & "   ADO Error   # " & .Number
                strTmp = strTmp & vbCrLf & "   Description   " & .Description
                strTmp = strTmp & vbCrLf & "   Source        " & .Source
                i = i + 1
            End With
        Next
0
 
Jose BredariolPMPAuthor Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.