Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

ADO connection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ADO connection

    Check out this article; Mike Faust "TechTip: Connect to the iSeries DB2 Database from an Active Server Page" 9/2/02 12:00pm it covers using ADO from an Active Server Page but it's the same concept. It looks like you're confusing the technique used for ADO with the technique used to access a ASCII text file.

  • #2
    ADO connection

    Mike Thank you for your article. I am trying to get the "command object" to work for me, I see this could be very useful when trying to call iSeries programs. I'm not having much luck at this, it seems to die on me when it hits on the objCmd.Execute, and the error is not helpful--here is the code if you have a minute to give advice. Sub test() On Error GoTo HandleError 'Create the connection and get the data Set cnn400 = New ADODB.Connection Set objcmd = New ADODB.Command Const cnnstring400 = "Provider=IBMDA400; Data Source=QMMA400;" cnn400.Open cnnstring400 objcmd.ActiveConnection = cnnstring400 ' objcmd.CommandText = "DELETE * FROM MMALIB.TESTP" cmd = "'DELETE * FROM MMALIB.TESTP'" objcmd.CommandText = "CALL QSYS.QCMDEXC(" & cmd & ")" objcmd.Execute-----(ERRORS OUT ON THIS STATEMENT with -2147467259 Automation error) cnn400.Close Set cnn400 = Nothing Set objcmd = Nothing HandleError: MsgBox Err.Number & " " & Err.Description End Sub[*]****************************** Thoughts would be appreciated!! Diane

    Comment


    • #3
      ADO connection

      I'm not sure if the code came through clearly. It looks like you may be doing some extra work here. You should simply be able to execute the DELETE command as shown below. Also when calling the QCMDEXC API you need to provide a second parameter that defines the length of the OS400 command provided. In the case of your example, however, I don't think this is what you want to do anyway. There's some good information on using ADO in the book "The iSeries and AS400 Programmer's Guide to Cool Things" from MC Press. Mike Faust mikeffaust@yahoo.com The iSeries and AS400 Programmer's Guide to Cool Things
      Code Active Server Pages Primer: The iSeries Definitive Guide to ASP

      Comment


      • #4
        ADO connection

        Mike Thank you for your article. I am trying to get the "command object" to work for me, I see this could be very useful when trying to call iSeries programs. I'm not having much luck at this, it seems to die on me when it hits on the objCmd.Execute, and the error is not helpful--here is the code if you have a minute to give advice. Sub test() On Error GoTo HandleError 'Create the connection and get the data Set cnn400 = New ADODB.Connection Set objcmd = New ADODB.Command Const cnnstring400 = "Provider=IBMDA400; Data Source=QMMA400;" cnn400.Open cnnstring400 objcmd.ActiveConnection = cnnstring400 ' objcmd.CommandText = "DELETE * FROM MMALIB.TESTP" cmd = "'DELETE * FROM MMALIB.TESTP'" objcmd.CommandText = "CALL QSYS.QCMDEXC(" & cmd & ")" objcmd.Execute-----(ERRORS OUT ON THIS STATEMENT with -2147467259 Automation error) cnn400.Close Set cnn400 = Nothing Set objcmd = Nothing HandleError: MsgBox Err.Number & " " & Err.Description End Sub[*]****************************** Thoughts would be appreciated!! Diane

        Comment


        • #5
          ADO connection

          Diane, If all you're trying to do is a SQL Update, Delete or Insert, than you can use the Connection Object's Execute Method, passing the SQL Statement. I frequently use this method in VB. Admittedly I'm not familiar with the ADODB Command Object but I don't think that it's necessary in this case. Mike

          Comment


          • #6
            ADO connection

            I'm looking for an example to get me started on a DSNLess ADO connection from a macro in MSACCESS to connect to an iSeries file. I'm confused as to where I define my file, the following is my connection string "Const cnnstring400 = "Provider=IBMDA400; Data Source=QMMA400;" and it works fine. Now, my file MYLIB.TESTP will always be an empty file that I write to. I've done some testing with this statement defining the file, it does not give me any errors nor does it write the record: "cnn400.Open cnnstring400 Open "MYLIB.TESTP" For Output As #1 FNAME = "Diane" Write #1, FNAME cnn400.Close Set cnn = Nothing Any examples would be greatly appreciated. Diane

            Comment


            • #7
              ADO connection

              I'm using an ACCESS front end that is currently can write a record directly to and AS400 resident database. This example might be able to help with some of your questions. Through trial and error, using SQL commands was the only way to get it to write or read properly. Oscar
              Code

              Comment

              Working...
              X