Results 1 to 14 of 14

Thread: runtime error 13 on update...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    runtime error 13 on update...

    i got the function below to execute an update command (access db), i got a runtime error 13 when i call the function but the the update is running in the database....any help why i got the error...


    Code:
    Public Function ExecuteSQLa(ByVal strSql As String, Optional ByRef RowsAffected As Long) As ADODB.Recordset
    Dim cmd As ADODB.Command
    lngRowsAffected = 0
      On Error Resume Next 'GoTo ExecuteSQLa_Error
    
      Set cmd = New ADODB.Command
      cmd.ActiveConnection = AccCon
      cmd.CommandText = strSql
      Set ExecuteSQLa = cmd.Execute(RowsAffected)
      lngRowsAffected = RowsAffected
      Set cmd = Nothing
    
       On Error GoTo 0
       Exit Function
    ExecuteSQLa_Error:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExecuteSQLa of Module modMain"
    End Function

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: runtime error 13 on update...

    Can you point out on which line this error occurs
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    Re: runtime error 13 on update...

    when i set the command

    Code:
     Set cmdCust = DBa.ExecuteSQLa(sqlCust)

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: runtime error 13 on update...

    can you just try removing the resume next statement and make it as
    vb Code:
    1. On Error GoTo ExecuteSQLa_Error
    and then tell us which line it gives error
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    Re: runtime error 13 on update...

    i did it ..same error same line,trying to debug it, pressing F8 from the set command line i got the runtime error on the Exit Function line (??)

  6. #6
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    On Error GoTo 0
    what does thi mean?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    Re: runtime error 13 on update...

    disables error handling in the current procedure

  8. #8
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    if that is the case then what is the use of having
    ExecuteSQLa_Error:
    First you use
    On Error Resume Next
    then
    On Error GoTo 0
    ????

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    Re: runtime error 13 on update...

    these are sample code lines trying to debug the error, without any of these lines i got the same runtime error...

  10. #10
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    you haven't dimmed
    lngRowsAffected = 0
    as you know error 13 is usually associated with datatype mismatch

  11. #11
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    I tried to duplicate what you might be doing. I didnot receive any error! Am I doing what you are doing??
    vb Code:
    1. Dim cmd As ADODB.Command
    2. Dim conn As Connection
    3. Private Sub Command1_Click()
    4. Dim cmdCust As ADODB.Recordset
    5.     Set cmdCust = ExecuteSQLa("Select * from BooksMaster")
    6.     MsgBox cmdCust.Fields(0)
    7. End Sub
    8. Private Function ExecuteSQLa(ByVal strSQL As String, Optional ByRef RowsAffected As Long) As ADODB.Recordset
    9. 'Dimmed lngRowsAffected
    10. Dim lngRowsAffected As Long
    11. lngRowsAffected = 0
    12. Set cmd = New ADODB.Command
    13.     cmd.ActiveConnection = conn
    14.     cmd.CommandText = strSQL
    15.     'Added this line
    16.     cmd.CommandType = adCmdText
    17.     Set ExecuteSQLa = cmd.Execute(RowsAffected)
    18.     lngRowsAffected = RowsAffected
    19.     Set cmd = Nothing
    20.     Exit Function
    21. End Function
    22.  
    23. Private Sub Form_Load()
    24.     Set conn = New ADODB.Connection
    25.     conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
    26.     & "Data Source = E:\My Documents\Projects\Books Maintenance\Database\books1.mdb"
    27.     conn.Open
    28. End Sub

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 2003
    Location
    Earth, I think!!
    Posts
    249

    Re: runtime error 13 on update...

    yes, its almost the same....but i got still error...(i added the line you add)

  13. #13
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    Dimming?

  14. #14
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: runtime error 13 on update...

    pls also watch out for this
    Dim cmdCust As ADODB.Recordset
    Set cmdCust = ExecuteSQLa(myQuery)
    is diff from yours
    Set cmdCust = DBa.ExecuteSQLa(sqlCust)
    what is DBa?

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