Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: ASP Connection to an AS400


Message #1 by "Drew, Ron" <RDrew@B...> on Wed, 16 May 2001 10:37:12 -0400
I need your Help out there...

I currently connect to a Microsoft SQL 6.5 server with no problems.

The question is:

How do I code the connect to an AS400 database that we now want to use?

Is it still an ODBC?  How do I point to a library?



This is an example of code I use for MS SQL 6.5.   Tell me what changes I

need please...

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

<!--<%@ Language=VBScript %>-->

<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common

Files\System\ado\msado15.dll" -->

<% 

'creates and returns a connection

function CreateConnection()

	on error resume next

	

	dim cnDB

	set cnDB = Server.CreateObject("ADODB.Connection")

		

	sQryConn  

"Provider=SQLOLEDB;SERVER=MYSERVER;UID=sa;DATABASE=sales;User

Id=sa;PASSWORD=;"

	cnDB.CursorLocation =adUseClient

	cnDB.Open (sQryConn )

	

	if Err <> 0 then

		set cnDB = nothing

		Response.Write("ERROR CONNECTING TO DATABASE, PLEASE LOG OUT

AND TRY AGAIN")

	else

		set CreateConnection = cnDB

	end if

end function

%>

Set myRS=server.CreateObject("ADODB.Recordset")

set myAdoConnection = CreateConnection()

     sQuery = "select * from stores"

 myRS.Open sQuery, myAdoConnection , adOpenStatic,adLockReadOnly 

 myRS.MoveLast

 if myRS.RecordCount <0 then

	  GetData ="No Data"

	  GetData=GetData & sQuery

	  exit function

	  else

	  myRS.MoveFirst

 end if

'   Then I just display it in a table







Ron 


  Return to Index