I am trying to connect to a Oracle database using this code. When I go to this page it only displays the HTML in the browser but when I view source I can see all of the asp code. It appears to never do the database connect and sql statement. Any ideas why this does not work?
Thanks
Paul
<%@ Language=VBScript %>
<html>
<head>
<title>Open Positions</title>
</head>
<body leftmargin="25">
<%
Option Explicit
Dim Ora_Conn As ADODB.Connection
Dim Ora_Rs As ADODB.Recordset
Dim sql
Dim dept
Dim loc
Dim where
Dim order
dept = Request.querystring("select1"
loc = Request.querystring("select2"
' The following if block creates the where and orderby clauses for the SQL query.
' The where clause must be custom built based upon the query selections made on the selections made on Default.asp
' Both department and location have a search value - search on both
if dept <> "All" and loc <> "All" then
where = where & " and division2 = '" & dept & "' and division3 = '" & loc & "' "
order = order & " title"
' Only location has search value - search on location
elseif dept = "All" and loc <> "All" then
where = where & " and division3 = '" & loc & "' "
order = order & " division2, title"
' Only department has search value - search on department
elseif dept <> "All" and loc = "All" then
where = where & " and division2 = '" & dept & "' "
order = order & " division3, title "
else
' Both selections are all
order = order & " division2, division3, title "
end if
' Create final SQL query string
sql = " SELECT req_number, formatted_req_number, title, division3, division2, salary_grade, source_posting_date_end FROM swa_posting" & where & order
Response.Write(sql)
' Instanciate the Oracle connection and recordset objects
Set Ora_Conn = New ADODB.Connection
Set Ora_Rs = New ADODB.Recordset
With Ora_Conn
.ConnectionString =
"Driver={Microsoft ODBC for Oracle};Server=dv;Uid=rep;Pwd=rep99;"
.Open
End With
' Open the recordset object -- NOTE: This open method executes the SQL query and populates the resultant table
Ora_Rs.Open sql, Ora_Conn
If Err.Number <> 0 Then
Response.Write "Error with SQL: " & sql & "<BR>" & Err.Description
end if
%>
<h2>Open Positions</h2>
<hr>
<table ID="Table1">
<%
Response.Write("<tr>"
Response.Write("<th>Title</th>"
Response.Write("<th>Location</th>"
Response.Write("<th>Grade</th>"
Response.Write("<th>Closes</th>"
Response.Write("<th>Department</th>"
Response.Write("<th>Requisition #</th>"
x = true
Do While(Ora_Rs.EOF = FALSE)
if x = true then
Response.Write("<tr bgcolor = 'CCCCCC'><td>"
x = false
else
Response.Write("<tr><td>"
x = true
end if
Response.Write("<a HREF=jobdetail.asp?reqid=" & (Ora_Rs.Fields("req_number"
.Value) & ">" & Ora_Rs.Fields("title"
.Value & "<\a>"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("division3"
.Value)
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("salary_grade"
.Value)
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("source_posting_date_end"
.Value)
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("division2"
.Value)
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("formatted_req_number"
.Value)
Response.Write("</td></tr>"
oRS.MoveNext
Loop
%>
</table>
<%
if Ora_Rs.BOF then
Response.Write("<i>No listings match your search criteria!</i>"
end if
%>
<%
' Close the Oracle recordset
Ora_Rs.Close
' Close the Oracle connection
Ora_Conn.Close
' Destroy the Oracle connection, recordset, and SQL string objects
Set Ora_Rs = Nothing
Set Ora_Conn = Nothing
Set sql = Nothing
%>
<hr>
<p align="center"><a href="javascript:history.back()">Start Over</a> </p>
</body>
</html>
Thanks
Paul
<%@ Language=VBScript %>
<html>
<head>
<title>Open Positions</title>
</head>
<body leftmargin="25">
<%
Option Explicit
Dim Ora_Conn As ADODB.Connection
Dim Ora_Rs As ADODB.Recordset
Dim sql
Dim dept
Dim loc
Dim where
Dim order
dept = Request.querystring("select1"
loc = Request.querystring("select2"
' The following if block creates the where and orderby clauses for the SQL query.
' The where clause must be custom built based upon the query selections made on the selections made on Default.asp
' Both department and location have a search value - search on both
if dept <> "All" and loc <> "All" then
where = where & " and division2 = '" & dept & "' and division3 = '" & loc & "' "
order = order & " title"
' Only location has search value - search on location
elseif dept = "All" and loc <> "All" then
where = where & " and division3 = '" & loc & "' "
order = order & " division2, title"
' Only department has search value - search on department
elseif dept <> "All" and loc = "All" then
where = where & " and division2 = '" & dept & "' "
order = order & " division3, title "
else
' Both selections are all
order = order & " division2, division3, title "
end if
' Create final SQL query string
sql = " SELECT req_number, formatted_req_number, title, division3, division2, salary_grade, source_posting_date_end FROM swa_posting" & where & order
Response.Write(sql)
' Instanciate the Oracle connection and recordset objects
Set Ora_Conn = New ADODB.Connection
Set Ora_Rs = New ADODB.Recordset
With Ora_Conn
.ConnectionString =
"Driver={Microsoft ODBC for Oracle};Server=dv;Uid=rep;Pwd=rep99;"
.Open
End With
' Open the recordset object -- NOTE: This open method executes the SQL query and populates the resultant table
Ora_Rs.Open sql, Ora_Conn
If Err.Number <> 0 Then
Response.Write "Error with SQL: " & sql & "<BR>" & Err.Description
end if
%>
<h2>Open Positions</h2>
<hr>
<table ID="Table1">
<%
Response.Write("<tr>"
Response.Write("<th>Title</th>"
Response.Write("<th>Location</th>"
Response.Write("<th>Grade</th>"
Response.Write("<th>Closes</th>"
Response.Write("<th>Department</th>"
Response.Write("<th>Requisition #</th>"
x = true
Do While(Ora_Rs.EOF = FALSE)
if x = true then
Response.Write("<tr bgcolor = 'CCCCCC'><td>"
x = false
else
Response.Write("<tr><td>"
x = true
end if
Response.Write("<a HREF=jobdetail.asp?reqid=" & (Ora_Rs.Fields("req_number"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("division3"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("salary_grade"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("source_posting_date_end"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("division2"
Response.Write("</td><td>"
Response.Write(Ora_Rs.Fields("formatted_req_number"
Response.Write("</td></tr>"
oRS.MoveNext
Loop
%>
</table>
<%
if Ora_Rs.BOF then
Response.Write("<i>No listings match your search criteria!</i>"
end if
%>
<%
' Close the Oracle recordset
Ora_Rs.Close
' Close the Oracle connection
Ora_Conn.Close
' Destroy the Oracle connection, recordset, and SQL string objects
Set Ora_Rs = Nothing
Set Ora_Conn = Nothing
Set sql = Nothing
%>
<hr>
<p align="center"><a href="javascript:history.back()">Start Over</a> </p>
</body>
</html>