Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could i retrieve a field from AS400 file to VB program?

Status
Not open for further replies.

ladeecroft

Programmer
Oct 6, 2003
19
PH
I'm trying to write a code in visual basic that allows the user to encode a product code and when the user clicks a button, the description of the product code must be displayed. The product description could be retrieved from an AS400 file. Is there a way for me to retrieve the description by just using the IP address of AS400 and vice versa?...could i also access a file outside AS400 in my RPG pgms by just using the connection through IP Address?

Please enlighten me.
 
1. for vb to access db2/400, I use the code like this:
...

Dim cnDataSource As ADODB.Connection
Dim rsData As ADODB.Recordset
Dim stConnect As String
Dim stSQL As String

stSQL = "select * from lib.file"
' create the connection string

stConnect = "Provider=IBMDA400;" & _
"Data Source=121.1.1.25;" _
"User ID=user;Password=password;"

' create the recordset object and run the query

Set cnDataSource = New ADODB.Connection
Set rsData = New ADODB.Recordset

cnDataSource.Open stConnect

' create the recordset object and run the query

rsData.Open stSQL, cnDataSource
...

2. for rpg to access files outside AS/400, you probably have to setup the remove database of it. Check these commands out:

WRKRDBDIRE
ADDRDBDIRE

I am sure you can specify the remote location with ip address.

Jerry Tseng
 
thanks for your reply jerry.

it was very helpful, i was able to access the AS400 file using ODBC, and instead of hardcoding the connection string parameters, i've just used the dsn name i've defined in the Client access driver.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top