RUN-Time error 3001 , Application defined or object defined error at rs.Open

  • Hi folks, I tried to write a VBA code to pass data from excel to MYSQL. Each time the code runs to rs.Open strSQL , conn, I get a run-time error 3001 , Application-defined or object-defined error. I cannot figure out where exactly the problem lies. Would appreciate if you can advise. Here's the code


  • Re: RUN-Time error 3001 , Application defined or object defined error at rs.Open


    I assume this is a typing error:


    Code
    Private Sub connect() 
        Dim rs As ADODB.RecordsetDim conn As New ADODB.Connection


    should be


    Code
    Private Sub connect() 
        Dim rs As ADODB.Recordset
        Dim conn As New ADODB.Connection


    rs.open cannot be used when using an insert sql-command.


    Try

    Code
    conn.execute strsql

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!