I do not know anything about VBasic Script and the programmer that did left the company and the company want me to make a change to the asp file.
A ".asp" Form has 5 fields. File looks for data in any one of the fields and does a SQL on the first field if finds info in. Company now wants a 2 field search instead of a one field search.
First table name is Projects, If it finds records in that table it wants a second SQL of the results of the cursor file
I can not get the code to work correctly, Can anyone point out the errors of my ways?
[tt]
<% Response.Buffer = True %>
<html>
<head><title> Projects </title></head>
<body>
<%
Dim adOpenKeySet
adOpenKeySet = 1
Dim adLockOptimistic
adLockOptimistic = 3
Dim adUseClient
adUseClient = 3
Dim lnSqlRun
lnSqlRun = 0
Dim lnRcount
lnRCount = 0
proj = UCase(Request.Form("ProjNum"
)
proj = LTrim(proj)
proj = RTrim(proj)
reqno = UCase(Request.Form("ReqNum"
)
reqno = LTrim(reqno)
reqno = RTrim(reqno)
lcBac = UCase(Request.Form("BacNum"
)
lcBac = LTrim(lcBac)
lcBac = RTrim(lcBac)
lcAgy = UCase(Request.Form("AgName"
)
lcAgy = LTrim(lcAgy)
lcAgy = RTrim(lcAgy)
title = UCase(Request.Form("ProjTitle"
)
title = LTrim(title)
title = RTrim(title)
title = Replace(title, "(", ""
title = Replace(title, "
", ""
title = Replace(title, "\", ""
title = Replace(title, "'", ""
title = Replace(title, " ", " "
title = Replace(title, " ", " "
title = Replace(title, " ", " "
title = Replace(title, " ", "%' AND Prjname LIKE '%"
If Not IsNull(proj) And (Len(proj) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE rtrim(Project) = '" & proj & "'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(reqno) And (Len(reqno) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE rtrim(Req_no) = '" & reqno & "'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(title) AND (Len(title) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE Prjname LIKE '%" & title & "%'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If lnSqlRun = 1 then
If Not IsNull(lcAgy) And (Len(lcAgy) > 0) And (lnSqlRun = 1) Then
lnSqlRun = 2
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
error occurs here
SQL = "SELECT * FROM bidsys WHERE Buyer = '" & lcAgy & "'"
rs.Open SQL, "DSN=bidsys1", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(lcBac) And (Len(lcBac) > 0) And (lnSqlRun = 1) Then
lnSqlRun = 2
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
error occurs here
SQL = "SELECT * FROM bidsys WHERE rtrim(Agency) = '" & lcBac & "'"
rs.Open SQL, "DSN=bidsys1", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
End If
If (lnSqlRun = 0) and (lnRCount = 0) Then
Response.Write "<H2>Please Data in the</H2>"
Response.Write "Project number, Requisition Number, Project Title, or Bureau Agency Code Fields."
Response.Write "<A HREF = 'projsrch.asp'> search page </A>"
End If
if (lnSqlRun > 0) and (lnRCount = 0) Then
rs.Close
Set rs = Nothing
Response.Write "<H2> No Data Matched Your Input. </H2>"
Response.Write "<A HREF = 'projsrch.asp'> Return to search page </A>"
End If
if (lnSqlRun > 0) and (lnRCount > 0) Then
etc
David W. Grewe
Dave@internationalbid.com
A ".asp" Form has 5 fields. File looks for data in any one of the fields and does a SQL on the first field if finds info in. Company now wants a 2 field search instead of a one field search.
First table name is Projects, If it finds records in that table it wants a second SQL of the results of the cursor file
I can not get the code to work correctly, Can anyone point out the errors of my ways?
[tt]
<% Response.Buffer = True %>
<html>
<head><title> Projects </title></head>
<body>
<%
Dim adOpenKeySet
adOpenKeySet = 1
Dim adLockOptimistic
adLockOptimistic = 3
Dim adUseClient
adUseClient = 3
Dim lnSqlRun
lnSqlRun = 0
Dim lnRcount
lnRCount = 0
proj = UCase(Request.Form("ProjNum"
proj = LTrim(proj)
proj = RTrim(proj)
reqno = UCase(Request.Form("ReqNum"
reqno = LTrim(reqno)
reqno = RTrim(reqno)
lcBac = UCase(Request.Form("BacNum"
lcBac = LTrim(lcBac)
lcBac = RTrim(lcBac)
lcAgy = UCase(Request.Form("AgName"
lcAgy = LTrim(lcAgy)
lcAgy = RTrim(lcAgy)
title = UCase(Request.Form("ProjTitle"
title = LTrim(title)
title = RTrim(title)
title = Replace(title, "(", ""
title = Replace(title, "
title = Replace(title, "\", ""
title = Replace(title, "'", ""
title = Replace(title, " ", " "
title = Replace(title, " ", " "
title = Replace(title, " ", " "
title = Replace(title, " ", "%' AND Prjname LIKE '%"
If Not IsNull(proj) And (Len(proj) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE rtrim(Project) = '" & proj & "'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(reqno) And (Len(reqno) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE rtrim(Req_no) = '" & reqno & "'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(title) AND (Len(title) > 0) And (lnSqlRun = 0) Then
lnSqlRun = 1
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
SQL = "SELECT * FROM projects WHERE Prjname LIKE '%" & title & "%'"
rs.Open SQL, "DSN=bidsys", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If lnSqlRun = 1 then
If Not IsNull(lcAgy) And (Len(lcAgy) > 0) And (lnSqlRun = 1) Then
lnSqlRun = 2
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
error occurs here
SQL = "SELECT * FROM bidsys WHERE Buyer = '" & lcAgy & "'"
rs.Open SQL, "DSN=bidsys1", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
If Not IsNull(lcBac) And (Len(lcBac) > 0) And (lnSqlRun = 1) Then
lnSqlRun = 2
Set rs = Server.CreateObject("ADODB.Recordset"
rs.CursorLocation = adUseClient
error occurs here
SQL = "SELECT * FROM bidsys WHERE rtrim(Agency) = '" & lcBac & "'"
rs.Open SQL, "DSN=bidsys1", adOpenKeySet, adLockOptimistic
lnRCount = rs.RecordCount
End If
End If
If (lnSqlRun = 0) and (lnRCount = 0) Then
Response.Write "<H2>Please Data in the</H2>"
Response.Write "Project number, Requisition Number, Project Title, or Bureau Agency Code Fields."
Response.Write "<A HREF = 'projsrch.asp'> search page </A>"
End If
if (lnSqlRun > 0) and (lnRCount = 0) Then
rs.Close
Set rs = Nothing
Response.Write "<H2> No Data Matched Your Input. </H2>"
Response.Write "<A HREF = 'projsrch.asp'> Return to search page </A>"
End If
if (lnSqlRun > 0) and (lnRCount > 0) Then
etc
David W. Grewe
Dave@internationalbid.com