Consultor Eletrônico



Kbase P12156: Sample ASP code to access a Progress Database
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   29/01/2003
Status: Unverified

GOAL:

Sample ASP code to access a Progress Database

FIX:

This solution applies to Progress SQL-92 Engine Version 9.1x. It
provides a sample Microsoft Active Server Pages program to access the
Progress SQL-92.

The connection in this sample 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.

NOTE: The Progress WebSpeed product can be used to web-enable
applications or to develop web applications accessing Progress
databases or Progress DataServer databases.
The Progress approach is scalable, portable, connects natively, and
allows deployment of compiled code among other features.

The program:


<html>
<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, name, creditlimit from pub.""customer"" where
custnum < 100"

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>

Reference to Written Documentation:

Progress SQL-92 Guide and Reference.

Progress ODBC Driver Guide.