-
Does anyone know the code to connect to a database on an AS400 using ASP/PWS? The database on the AS400 is a DB2 and i need to connect to this and display fields in a table on an webpage using ASP. Help me please I have been trying but don't know what I am doing!
-
If you have an ODBC data source setup for the AS/400 (you should have an ODBC driver for the AS/400), then you can do it like you can do with any other ODBC databases:
Code:
<%
Dim cn
On Error Resume Next
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open DSN=YourDSNName", "UserName", "Password"
If Err.number <> 0 Then
Response.Write "Error connection to database<BR>"
Response.Write Err.Number & " " & Err.Description & "<BR>"
Response.End
End If
'Here do your stuff after you connect to a database...
%>
-
ASP
If you are after ASP you should try
http://www.experts-exchange.com
Free and lots of help...if you join up I could use the
credit...vbWayne
-
Thankyou Serge for answering so quickly, this is working better but I still get an error that reads:
-2147467259 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
in the code that you posted above in this line:
cn.Open DSN=YourDSNName", "UserName", "Password"
DSN=YourDSNName I am entering what the name of the driver says when i look at settings/control panel/ODBC Datasources (32bit)/system DSN tab there is the DSN name and driver and i tried both in that part of the code. Does the name go there then I specify the driver seperately? And if so how do I specify the driver?
Thankyou very much for your help!
PS HeSaidJoe, I will definately look into this for future use I am just working on a deadline and just knew that one of you extremely smart people out there would know the answer! And hey, I was right! :)
-
When you creating a DSN in the ODBC applet (Control Panel), the driver is specified there along with the name for your Data source, so no other settings are required in the code.
So if you've created a DSN for the AS/400 database, it should remember the driver as well. Instead of UserName and Password you should use the real UserName and Password for the database, either given to you by database administrator.
-
I was putting in my userID and password, so I guess I will have to check with them to see if that would work. I set up the DSN of the AS400 on my machine and could even link to the tables and fields from the Get external data tab in access so I guess that would mean that the connection is good. I will have to play around with it some more and see what I can figure out. Please let me know if you have any more ideas. THANK YOU!!!!