Results 1 to 10 of 10

Thread: connecting to As/400 & uploading files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71

    Question connecting to As/400 & uploading files

    Hio..

    I have been given the task of establishing a connection to As/400 through VB and then uploading PC files to AS/400. Can anyone help me...
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  2. #2
    Member
    Join Date
    Nov 2000
    Posts
    43
    What connect methods do you have available?? Do you have Client Access?? If so below is a method to connect and send files

    Set autECLConnMgr = CreateObject("PCOMM.autECLConnMgr") 'create conn manager object
    Set Session = CreateObject("PCOMM.autECLSession") 'Create session object

    autECLConnMgr.StartConnection ("PROFILE=AS/400.ws WINSTATE=MINIMIZE") ' starts session

    autECLConnMgr.autECLConnList.Refresh
    autECLSession.SetConnectionByHandle(autECLConnMgr.autECLConnList(1).Handle)
    ' For example, send the file to VM
    autECLSession.autECLXfer.SendFile"c:\windows\temp\thefile.txt", "THEFILE TEXT A0", "CRLF ASCII"
    The forgoing examples require Client Access and references to PCOMM Object libraries.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    thanks for that code.. I was wondering why there is no asking for the username and password and AS/400 system. I will need to have the user input these and then connect. Do you know how.

    Oh I am using client access..
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  4. #4
    Member
    Join Date
    Nov 2000
    Posts
    43
    User login is system specific, but most that i deal with prompt the user for name and password as soon as a connection is made. Some systems prompt for user and password each time a function change is made such as going form a user App to an ODBC data request.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    my program will require the user to enter their username , password first then the connection to the AS/400 is executed. Also I do not want to display an as/400 screen.. I just want the connection to perform the upload/download of information (files).

    have you done anything like this before?
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  6. #6
    Member
    Join Date
    Nov 2000
    Posts
    43
    I do this all the time. following is a few snippets of the logon process.
    Public SubStartConn(Profile, winState)
    ' Profile is the .ws file in the \program files\ibm\Client Access\ Emulator\private directory which sets the '
    ' startup environment for Client Accesss
    Dim StartStr As String

    ' Start a PCOMM connection, i.e. open a PCOMM window.
    StartStr = "PROFILE=" + Profile

    If Not (StartName = "") Then
    StartStr = StartStr + " CONNNAME=" + StartName
    End If
    Select Case winState
    Case "Min"
    StartStr = StartStr + " WINSTATE=MIN"
    Case "Max"
    StartStr = StartStr + " WINSTATE=MAX"
    Case "Hide"
    StartStr = StartStr + " WINSTATE=HIDE"
    Case Else
    StartStr = StartStr + " WINSTATE=RESTORE"
    End Select

    autECLConnMgr.StartConnection (StartStr)


    End Sub

    Public Sub AS400Connect()

    hwndSignon = FindWindow(CLng(0), "Signon to AS/400") ' get main
    Loop Until hwndSignon > 0
    hWndFind = FindWindowEx(hwndSignon, 0, "Edit", vbNullString) ' get first child
    i = 0
    'go through the rest of the children
    Do Until hWndFind = 0
    'if you get here, hWndFind is the handle to an edit control, so do something with it
    If i = 1 Then
    SendMessageByStr hWndFind, WM_SETTEXT, 0, UserName ' UserName is the second Edit box
    End If
    If i = 2 Then
    SendMessageByStr hWndFind, WM_SETTEXT, 0, UserPassword ' UserPassword is the third Edit box
    End If
    i = i + 1
    'look for the next edit control
    hWndFind = FindWindowEx(hwndSignon, hWndFind, "Edit", vbNullString)
    Loop
    hWndFind = FindWindowEx(hwndSignon, 0, "Button", "OK") ' get OK Button
    retval = SendMessage(hWndFind, BM_CLICK, ByVal CLng(0), ByVal CLng(0))

    End Sub

    If you do not need to start Client Access then your initial connect interaction with the AS/400 will be adequate for file transfer. I would expect that the system will ask for Username and Password when you first connect and possibly when you execute the file transfer request. When that happens use the AS400Connect sub to find the signon window and fill in the boxes for you.
    Last edited by oldharley; Sep 28th, 2001 at 08:50 AM.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    will this bring up an as/400 screen, cause that is not what I want. I just want to connect.. not show a screen.
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  8. #8
    Member
    Join Date
    Nov 2000
    Posts
    43
    MAX and RESTORE will show a AS/400 screen. I edited the code to show another option - HIDE. MIN and HIDE will not show operational screens. They will however show the logon screen for which the above code logs on to the AS/400.

    There are other ways to connect also. You can use ADOB to connect as follows.


    Dim connectionAS400 As ADODB.Connection
    Dim rsAS400 As ADODB.Recordset

    'Create the connection
    Set connectionAS400 = New ADODB.Connection
    Set rsAS400 = New ADODB.Recordset
    connectionAS400 .ConnectionString = "DSN=YourAS/400;
    DRIVER=Client Access ODBC data Source;
    SERVER=servername;
    DATABASE=AS400libraryName;UID=userid;PWD=pword;"

    connectionAS400 .Open
    Set rsAS400 .ActiveConnection = connectionAS400
    Last edited by oldharley; Sep 28th, 2001 at 09:07 AM.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    71
    hey .. great thank you.. I think I am missing someything though. I am getting an error... [Mircosoft][ODBC driver manager] Data source name not found and no default driver specified..

    any advice... (ps I am lost)
    Madeline
    Just remember this "Until you do what you believe in, you don't know whether you believe it or not"

  10. #10
    Member
    Join Date
    Nov 2000
    Posts
    43
    First look to see that Client Access ODBC Driver(32-bit) is in the available driver list. If not, reinstall client access express and select ODBC drivers to reinstall. If it is available then you must a new DSN = whatever name you would like to give it. Once this DSN is added then you should not see the driver errror. Configuring the DSN will require that you ask the AS/400 administrator to give you all the default settings.

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