Consultor Eletrônico



Kbase 20158: Sample ASP Program to access Progress Database via SQL-92 Engine
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/18/2008
Status: Verified

GOAL:

How to access Progress SQL-92 via a sample Microsoft Active Server Pages program.

GOAL:

How to access a Progress database via ASP?

GOAL:

Sample ASP pages to access Progress database via SQL-92

FACT(s) (Environment):

Progress 9.1x

FIX:

The connection is done via ODBC. It uses a System data source name (DSN). User name and password should be specified to in the connection.

The program assumes that there is a sports2000 database running on your local system using port 2500 which is specified in the DSN. Also, the example uses user "dba1" with a password of "password" entered at the connection string.
The following code uses the ASP statement On Error Resume in order to handle ODBC error and warning messages at the program level. The On Error statement can be used to avoid the display of the following ODBC warning messages:


- [MERANT][ODBC PROGRESS driver]Optional feature not implemented.

- [MERANT][ODBC PROGRESS driver]Driver's. The program provides a variable called mydebug and the procedure
DisplayODBCErrors to display the errors if the variable is set to true.


The program:

<hmtl>
<title>Sample ASP Page Using Progress SQL-92 database</title>
<body>

Time: <%=now%><br>

<%
On Error Resume Next
Dim mydebug
mydebug = false

' DSN defined as db=sports2000;host=localhost;port=2500

myDSN = "dsn=p91a;uid=dba1;pwd=password"
mySQL = "select custnum, creditlimit from pub.""customer"""

set conntemp = server.createobject("adodb.connection")
conntemp.open myDSN

response.write "Err.Number = "
response.write (Err.Number)
response.write " Conntemp.Errors.Count = "
response.write (conntemp.Errors.Count)

DisplayODBCErrors()
%>

<br>

<table border="2">
<%
set rstemp = conntemp.execute(mySQL)

DisplayODBCErrors()

if rstemp.eof then
response.write "No record matched<br>"
conntemp.close
set conntemp = nothing
response.end
end if

do until rstemp.eof %>
<tr><td> <%=rstemp(0) %> </td><td><%=rstemp(1) %> </td><td>
<%=rstemp(2) %> </td></tr>
<%
rstemp.movenext
loop
%>

</table>

<%
rstemp.close
set rstemp = nothing

Response.end

conntemp.close
set conntemp = nothing
%>

<% Function DisplayODBCErrors() %>
<br>
<% if mydebug and (conntemp.Errors.Count > 0) then %>
<br><br><b>ODBC Connection Error and Warning Messages</b><br>
<% For intLoop = 0 To conntemp.Errors.Count - 1 %>

Error No: <%= conntemp.Errors(intLoop).Number %><BR>
Description: <%= conntemp.Errors(intLoop).Description %><BR>
Source: <%= conntemp.Errors(intLoop).Source %><BR>
SQLState: <%= conntemp.Errors(intLoop).SQLState %><BR>
NativeError: <%= conntemp.Errors(intLoop).NativeError %><P>

<% Next %>
<% end if %>
<% End Function %>

</body>
</html>


FIX:

References to Written Documentation:

Progress SQL-92 Guide and Reference

Progress ODBC Driver Guide