|
Justin, Many and several. Here's a code snippet: ' Global.ASA file contains the following information: ' - Userid ' - Password ' - AS/400 System Name ' - ODBC data source name <!-- Global.asa Session level variables --> <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Session_OnStart Session("AS400_Userid") = "UID" Session("AS400_Password") = "PASS" Session("AS400_SystemName") = "CAXPRESSCONNECTIONNAME" End Sub </SCRIPT> Active server page code snippet: 'Always DIM your variables, even though you don't have to. 'All ASP variables are variants, you cannot specify the data 'type Dim AS400Connection Dim AS400Command Dim AS400Recordset Dim ConnectionString Dim CommandText Dim CommandType On Error Resume Next 'Setup appropriate connection string and command information ConnectionString = "Provider=IBMDA400;Data Source=" & Session("AS400_SystemName") & ";" CommandType = adCmdText CommandText = "SELECT FIELDS FROM LIBRARY.FILE " _ & "WHERE CONDITIONS " _ & "ORDER BY STUFF" 'Open the connection Set AS400Connection = Server.CreateObject("ADODB.Connection") AS400Connection.Open ConnectionString,Session("As400_Userid"),Session("AS400_Passwo rd") Set AS400Command = Server.CreateObject("ADODB.Command") AS400Command.ActiveConnection = AS400Connection 'Specify Read-Only. This is a custom property 'only for the IBMDA400 object. AS400Command.Properties("Updatability") = 0 'Set the command to execute AS400Command.CommandText = CommandText AS400Command.CommandType = CommandType 'Execute the command on the AS/400 Set AS400Recordset = AS400Command.Execute If (Err.Number = 0 ) Then 'do stuff Else 'An Error Occurred DisplayError AS400Connection, Err.Number, Err.Description, Err.Source, "Main" End If AS400Recordset.Close Set AS400Recordset = Nothing Set AS400Conection = Nothing Set AS400Command = Nothing '************************************************************* ************************* '*** '*** Subroutine DisplayError '*** '************************************************************* ************************* Sub DisplayError(Connection,errNum,errDesc,errSource,proc) On Error Resume Next Response.Write("<br>VB Error Number: <b>" & errNum & " [0x" & Hex(errNum) & "]</b>") Response.Write("<br>Err.Description: <b>" & errDesc & "</b>") Response.Write("<br>Err.Source: <b>" & errSource & "</b>") Response.Write("<br>Procedure: <b>" & proc & "</b>") Response.Write("<br>Connection errors: <b>" & Connection.Errors.Count & "</b>") If (Connection.Errors.Count > 0) Then For Each ErrorMsg in Connection.Errors Response.Write("<br>" & ErrorMsg.Description) Next End If End Sub Some caveats: This works best with client access express v4r5 or better on the server presenting the asp. No ODBC data source is necessary, but you must install the data access objects (which install by default) On 23 Jan 2002 at 13:31, Justin Houchin wrote: > Hello, > Has anybody created an ASP Webpage that pulled data from the AS/400? I am >having a problem getting the web Page to see the ODBC connection. I think that >my ODBC Connection is not set up correctly. > > > Justin Houchin > Lead Programmer > Reliatek, Inc ----------------------------------------- Christopher J. Devous Director of Systems Development The Antigua Group, Inc. phone: (623) 523-6000 xt. 2238 (800) 562-9777 xt. 2238 fax: (623) 523-6008 http://www.antigua.com mailto:cdevous@antigua.com -----------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.