ASP and AS/400

J

Jack

Hi,

Using VbScript in an ASP page, I want to access a database stored on the
AS/400. Should I use ADO, ODBC or anyother way of doing it?

And is it possible to have some sample codes?

Thanks

Jack
 
R

Ray at

Treat it just like any other data source. If you have OLEDB drivers for
DB2, use them. If you only have ODBC, use them. IBM's Client Access [even
Express] comes with both, and you can choose to just install the drivers on
your IIS server without installing the full CA application. One of the only
things I know to watch out for is to never end your queries with a ;. And
just think LIBRARY=database, FILE=table. Here is sample code using IBM's
OLEDB drivers:




Function ReturnCIFArray(BankNumber, JulianDate)


sDB2String = "Provider=IBMDA400.DataSource.1;Persist Security
Info=False;User ID=AnAS400UserID;Password=ValidPassword;Data
Source=HOST_NAME_OR_AS_400_IP_ADDRESS;Catalog Library
List=LIBRARY1,LIBRARY2,LIBRARY3"

sDB2SQL = sDB2SQL & "SELECT LIBRARY1.FILE1.MEMBER1 FROM LIBRARY1.FILE1
WHERE LIBRARY1.FILE1.MEMBER2='some value'"

Set oDB2ADO = Server.CreateObject("ADODB.Connection")
oDB2ADO.Open sDB2String

Set SomeRecordset = oDB2ADO.Execute(sDB2SQL)
If Not SomeRecordSet.EOF Then TheResults = SomeRecordSet.GetRows()
SomeRecordSet.Close : Set SomeRecordSet = Nothing
oDB2ADO.Close
Set oDB2ADO = Nothing

Fully qualifying the files isn't necessary if you're only looking in one
library, but for illustration purposes, I qualified them and included a
library list in the connection string.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top