Hi all, I've got a problem with the following ASP code. I'm writing a search page (interface) using VBScript to connect to an Oracle 9i database. The problem is that I get a blank page (no results) from my SQL query.
Using Response.Write strSQL, I copied the string of SQL statement displayed and ran thru it in my database.Well, the SQL statement worked perfectly but when parsed in the ASP page no results displayed.
The following is my code:
<HTML>
<HEAD></HEAD>
<BODY>
<%
'Connection using execute method and a string variable
Dim connectionToDatabase, strconnection, recordset
Dim AD, KW, Pub, Cat, CNT
Dim strSQL
strDay = Request.Form("Day"
strMonth = Request.Form("lstMonths"
strYear = Request.Form("Year"
AD = "'" & strDay & "-" & strMonth & "-" & strYear & "'"
KW = "'" & Request.Form("Keyword"
& "'"
Pub = "'" & Request.Form("Publication"
& "'"
Cat = "'" & Request.Form("Category"
& "'"
CNT = "PUBLICATIONS.PUB_ID||CATEGORY.CAT_ID||ARTICLEDATE.DATE_ID||KEYWORD.KEYWORD_ID"
strconnection = "PROVIDER=OraOLEDB.Oracle; Data Source=databasename; User ID=user; PASSWORD=password;"
strSQL="Select LINK.LINK, PUBLICATIONS.PUB_ID, CATEGORY.CAT_ID, ARTICLEDATE.DATE_ID, KEYWORD.KEYWORD_ID from LINK, PUBLICATIONS, CATEGORY, ARTICLEDATE, KEYWORD where PUBLICATIONS.PUBLICATIONS="&Pub&" and CATEGORY.CATEGORY="&Cat&" and ARTICLEDATE.ART_DATE="&AD&" and KEYWORD.KEYWORDS="&KW&" and LINK.AID="&CNT&""
Set connectionToDatabase=Server.CreateObject("ADODB.Connection"
connectionToDatabase.open strconnection
Set recordset=connectionToDatabase.Execute(strSQL)
Do While Not recordset.EOF
%><a href="<%=Response.Write(recordset("LINK"
)%>"><%=Response.Write(recordset("LINK"
)%></a><%
Response.Write("<BR>"
recordSetLINK.MoveNext
Loop
' Close our recordset and connection and dispose of the objects
connectionToDatabase.Close
Set connectionToDatabase = Nothing
%>
</BODY>
</HTML>
*I'm using a variable called CNT to replace the whole concatenation statement. Note that it's number data type so don't think single quotes are required here.
Anyone got an idea why i'm not displaying any results?
Using Response.Write strSQL, I copied the string of SQL statement displayed and ran thru it in my database.Well, the SQL statement worked perfectly but when parsed in the ASP page no results displayed.
The following is my code:
<HTML>
<HEAD></HEAD>
<BODY>
<%
'Connection using execute method and a string variable
Dim connectionToDatabase, strconnection, recordset
Dim AD, KW, Pub, Cat, CNT
Dim strSQL
strDay = Request.Form("Day"
strMonth = Request.Form("lstMonths"
strYear = Request.Form("Year"
AD = "'" & strDay & "-" & strMonth & "-" & strYear & "'"
KW = "'" & Request.Form("Keyword"
Pub = "'" & Request.Form("Publication"
Cat = "'" & Request.Form("Category"
CNT = "PUBLICATIONS.PUB_ID||CATEGORY.CAT_ID||ARTICLEDATE.DATE_ID||KEYWORD.KEYWORD_ID"
strconnection = "PROVIDER=OraOLEDB.Oracle; Data Source=databasename; User ID=user; PASSWORD=password;"
strSQL="Select LINK.LINK, PUBLICATIONS.PUB_ID, CATEGORY.CAT_ID, ARTICLEDATE.DATE_ID, KEYWORD.KEYWORD_ID from LINK, PUBLICATIONS, CATEGORY, ARTICLEDATE, KEYWORD where PUBLICATIONS.PUBLICATIONS="&Pub&" and CATEGORY.CATEGORY="&Cat&" and ARTICLEDATE.ART_DATE="&AD&" and KEYWORD.KEYWORDS="&KW&" and LINK.AID="&CNT&""
Set connectionToDatabase=Server.CreateObject("ADODB.Connection"
connectionToDatabase.open strconnection
Set recordset=connectionToDatabase.Execute(strSQL)
Do While Not recordset.EOF
%><a href="<%=Response.Write(recordset("LINK"
Response.Write("<BR>"
recordSetLINK.MoveNext
Loop
' Close our recordset and connection and dispose of the objects
connectionToDatabase.Close
Set connectionToDatabase = Nothing
%>
</BODY>
</HTML>
*I'm using a variable called CNT to replace the whole concatenation statement. Note that it's number data type so don't think single quotes are required here.
Anyone got an idea why i'm not displaying any results?