Consulting

Results 1 to 9 of 9

Thread: Transfer Data from a Database

  1. #1
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location

    Transfer Data from a Database

    I'm trying to transfer data from the AS/400 to a Excel workbook. But I'm still getting a error.

    [VBA]
    Sub Transfer_File()
    Dim rst As ADODB.Recordset
    Dim strSQL As String

    strSQL = "Select * from B400.DEVIN100"

    Set rst = New ADODB.Recordset

    ' xxx = your as/400 ip address

    rst.Open strSQL, "Provider=IBMDA400;Data Source=204.254.X.XXX;"

    Range("A2").CopyFromRecordset rst

    End Sub
    [/VBA]


    I'm getting a error along this line:

    [VBA]
    rst.Open strSQL, "Provider=IBMDA400;Data Source=204.254.X.XXX;"
    [/VBA]


    I installed the Visual Basic reference:

    Microsoft ActiveX Data Objects 2.7 Library.

    Am I missing something?

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    What error are you getting?

    Are you sure the connection string is correct?

  3. #3
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by Norie
    What error are you getting?

    Are you sure the connection string is correct?

    It highlights this line:

    [VBA]
    rst.Open strSQL, "Provider=IBMDA400;Data Source=204.254.X.XXX;"
    [/VBA]


    Run-Time error '3706'

    Provider Cannot be found, It may not be properly install.


    What do you think it might be?

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    I'm no expert with this type of thing but it sounds to me that you may be missing some sort of driver for the database you are trying to connect to.

    Can you connect to the database through Data>Get External Data...?

  5. #5
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by Norie
    I'm no expert with this type of thing but it sounds to me that you may be missing some sort of driver for the database you are trying to connect to.

    Can you connect to the database through Data>Get External Data...?
    Yes and it works but it takes extremely slow. Doing through a code is much more faster. I do have a ODBC driver set up that is how I was able to do External Data. But do you might have a sample code that I could use that it worked for you?

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    I'm sorry but I can't give you any sample code.

    Like I said I'm no expert at this sort of thing, I prefer to work, if possible, with the data at it's source or another database eg Access.

    How did you get the code you have?

    Have you tried recording a macro when you go through Data>Get External Data...?

    By the way how do you know it'll be faster in code?

  7. #7
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    It is a driver missing. What OS are you using? If 95 0r 98 try referencing ADO 2.5.
    Peace of mind is found in some of the strangest places.

  8. #8
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Quote Originally Posted by Norie
    I'm sorry but I can't give you any sample code.

    Like I said I'm no expert at this sort of thing, I prefer to work, if possible, with the data at it's source or another database eg Access.

    How did you get the code you have?

    Have you tried recording a macro when you go through Data>Get External Data...?

    By the way how do you know it'll be faster in code?

    Yes now I know your no expert but maybe I thought you could've help because you responded to my thread.



    Thanks for responding austenr my OS is Microsoft Office 2003 I did trying to use that reference but it did work it might be some security issues with the AS/400 I probably will have to talk to one of the RPG programmers here at work. I'll let you know the outcome.

    Thanks!

  9. #9
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    I would suggest you build your connection string through a .udl file, then use that as a datasource in your macro code. In my experience with AS400 - the connection strings normally contained Catalog= or Library= parameters.

    If you are unfamilar with UDL's this should help

    http://msdn.microsoft.com/library/de...aLinkFiles.asp

    .02

    Stan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •