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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access a DB2 database using ASP

Status
Not open for further replies.

edgonz

IS-IT--Management
Jul 9, 2001
6
US
Is there a way to access a DB2 database on an AS/400 with ASP? I'd like to be able to have my users create queries on the web browser then execute those on a DB2 database on an AS/400 box.
Any ideas are greatly appreciated.


Edward.
 
Set Connection = Server.CreateObject( "ADODB.Connection" )
Connection.Open "Driver={Microsoft dBase Driver (*.dbf)};DriverId=533;FIL=dBase 5.0;DBQ="&pathtofile+"\filename.dbf"&";ReadOnly=0;UID=admin;"

<%
Const adOpenStatic = 3
Const adUseClient = 3
Const adLockPessimistic = 2

set rs=server.CreateObject(&quot;ADODB.Recordset&quot;)

sub ExecuteSQL(byval cmd)
if rs.State=1 then rs.Close
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockPessimistic
rs.Source = cmd
rs.ActiveConnection = Connection 'The record set needs to know what connection to use.
rs.Open
end sub

...

SQL=&quot;select * from MyDatabaseName&quot;
ExecuteSQL(SQL)
RecNo=rs.RecordCount
...
 
Sorry there is an error
u have to use it without &quot;<%&quot;
 
Shaddow,


Thanks for your reply. I must admint that I'm a beginner to ASP and I was wondering if there was some sample code I could use. Where would I put this code on the asp page?
The OS/400 programmer created a test DB called SAMPLEDB2 on the DEVLIB library and added some dummy data to play with. I imagine I can add that info in the DBQ= section, right?
I appreciate your help on this problem.
 
U use Dbase database?
If this is'n work tell me and i send to u an sample...
 
I use DB2 (IBM) on an AS/400 machine.
And it appears that the code is not working for me.
 
What U use NT, 2000?
Can u use an Access database or SQL?
 
I'm running IIS 4 on an NT 4 server. All SPs loaded.
I can use them, but I need to access the IBM DB2 database instead. My company's main DB system runs on our AS/400 and we use DB2 instead of MS-SQL.
 
Try to create an DSN to the database and use this DSN to connect to the database...
 
Hello,
As far as I know you are in trouble when trying to connect to DB2 from ASP.
See MSDN article
You will need
OLE DB Provider for DB2 (it seem not to be free) in order to access your database.

Or ODBC Driver for DB2

Wish you success!
D.
 
Hmm...is there another way I can have access to DB2 data on an AS/400? Do you know if those ODBC drivers are free?

Thanks.
 
Hello,
Seems that MS OLE DB and ODBC drivers come with installation of SNA Server, which is not free.

Try to look what IBM provides:
There is a DB2 Personal Developer's Edition which is free.

Even more links for ODBC drivers
(most of them have 30-90 days preview).

A gude for installing and configuring DB2 Clients

Success!
D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top