|
-
Sep 24th, 2001, 09:49 AM
#1
Thread Starter
Lively Member
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"
-
Sep 25th, 2001, 08:19 AM
#2
Member
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.
-
Sep 26th, 2001, 08:45 AM
#3
Thread Starter
Lively Member
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"
-
Sep 26th, 2001, 09:23 AM
#4
Member
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.
-
Sep 26th, 2001, 11:00 AM
#5
Thread Starter
Lively Member
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"
-
Sep 26th, 2001, 05:42 PM
#6
Member
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.
-
Sep 28th, 2001, 08:07 AM
#7
Thread Starter
Lively Member
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"
-
Sep 28th, 2001, 08:53 AM
#8
Member
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.
-
Sep 28th, 2001, 10:53 AM
#9
Thread Starter
Lively Member
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"
-
Oct 2nd, 2001, 11:07 AM
#10
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|