CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Location
    Texas, USA
    Posts
    4

    Unexplainable Error on Update

    Hi,
    I am trying to use ADODB objects to access an ACCESS 2000 db from VB.

    I am using the following code:
    (I should tell you that the command and recordset objects have been initialized and connected accordingly. I have used all these objects elsewhere in the code without problem. The names of the Command and Recordset objects show which are related.)


    objArchCMDLocal.CommandText = _
    "SELECT * FROM PdbJobInfo WHERE AutoKeyas < 0"
    objArchRSLocal.Requery
    '
    strSql = "SELECT * FROM PdbJobInfo WHERE JobId = " & CurJobId(0)
    '
    objActCMDLocal.CommandText = strSql
    objActRSLocal.Requery
    '
    If Not objActRSLocal.EOF then
    NumFields = objActRSLocal.Fields.Count
    '
    Do While Not objActRSLocal.EOF
    objArchRSLocal.AddNew
    '
    for Ndx = 0 to (NumFields - 1)
    Field = objActRSLocal(Ndx).Name
    Value = objActRSLocal(Ndx).Value
    If Field = "JobId" then
    objArchRSLocal(Field) = CurJobId(1)
    ElseIf Field = "AutoKey" then
    'objArchRSLocal(Field) = 1
    else
    objArchRSLocal(Field) = Value
    End If
    next
    '
    objArchRSLocal.Update
    objActRSLocal.MoveNext
    Loop
    '
    End If




    I have also attempted to use direct access (below) in place of the for loop through the fields...


    objArchRSLocal.Fields("JobId").Value = CurJobId(1)
    objArchRSLocal.Fields("Variable").Value = _
    objActRSLocal.Fields("Variable").Value
    objArchRSLocal.Fields("StrVal").Value = _
    objActRSLocal.Fields("StrVal").Value
    objArchRSLocal.Fields("VarType").Value = _
    objActRSLocal.Fields("VarType").Value






    When the Update is hit, I always get:
    "[Microsoft][ODBC Microsoft Access Driver]Invalid descriptor index "


    The table being accessed contains the following fields:
    1) AutoKeyVal (auto increment - key value)
    2) JobId (int)
    3) Variable (text)
    4) StrVal (text)
    5) VarType (Byte)

    The two different Recordsets refer to different databases. The db's have matching tables with identical fields. And there is data is the objActRSLocal recordset.

    I am totally out of ideas... anyone got any suggestions?

    Thanks...
    -Bill


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Unexplainable Error on Update

    What statement is giving you the error?

    John G

  3. #3
    Join Date
    Apr 2001
    Location
    Texas, USA
    Posts
    4

    Re: Unexplainable Error on Update

    The error occurs on the actual update call..


    objArchRSLocal.Update





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

Featured