-
dbreset?
Here is the jist of my problem.
I have constructed my own search engine and it gives the user the option of filtering the data. If a search comes back with more than 10 records, clicking on the Next button does not give the correct results. Pressing the Previous button doesn't come close to getting the original results returned. I have used many variations of the dbreset w/o any luck. Below I have included the code for the results. The '*** comments are about the dbreset code tried. What I am I doing wrong?? Thanks in advance.
<% @ Language=VBScript %>
<!-- #include file="../../includethis.inc"-->
<% checkcookee() %>
<% Response.Buffer = True %>
<!-- * Page Function - Display Search Results in Table * -->
<HTML>
<HEAD>
<TITLE>Search Results</TITLE></HEAD>
<SCRIPT LANGUAGE="JavaScript">
function again() {
document.location="search.asp"
}
function visitSite() {
document.location="../default.asp"
}
</SCRIPT>
</HEAD>
<BODY ALINK="Red" VLINK="Navy" LINK="Blue" bgcolor="White">
<div align="center"><h2>Query Results</h2></div>
<hr>
<%
Session( "searchword" ) = request.form("searchword"
Session( "searchword1" ) = request.form("searchword1"
Session( "cat" ) = request.form("category"
Session( "type1" ) = request.form("testtype"
Session( "person" ) = request.form("username"
' *** from the dbreset example -using this made the Next button display nothing
'If (Session( "searchword" ) <> "" Or Session( "searchword1" ) <> "" Or Session( "cat" ) <> "" Or Session( "type1" ) <> "" Or Session( "person" ) <> "" ) then
' Create the ASP-db object:
Set MyDb = Server.CreateObject("ASPdb.Pro"
' Use YourFile.mdb in the current directory:
MyDb.dbDSN = "K_base"
MyDb.dbUnit=102
SQL = "Select main.id, main.problem, type.type_name, category.cat_name, employees.last_name FROM Main, Type, Category, Employees WHERE ("
If (Session( "searchword" ) <> "" ) then
SQL = SQL + " main.problem Like '%" + Session( "searchword" ) + "%' AND"
End If
If (Session( "searchword1" ) <> "" ) then
SQL = SQL + " main.symptoms Like '%" + Session( "searchword1" ) + "%' AND"
End If
If (Session( "cat" ) <> "" ) then
SQL = SQL + " main.category = " + Session( "cat" ) + " AND"
End If
If (Session( "type1" ) <> "" ) then
SQL = SQL + " main.type = " + Session( "type1" ) + " AND"
End If
If (Session( "person" ) <> "" ) then
SQL = SQL + " main.username = " + Session( "person" ) + " AND"
End If
SQL = SQL + " main.type = type.type_id AND main.category = category.cat_id AND main.username = employees.emp_id "
SQL = SQL + ""
' ***** from the dbreset example
If (request.form("searchword" <> "" Or request.form("searchword1" <> "" Or request.form("category" <> "" Or request.form("testtype" <> "" Or request.form("username" <> "" ) then
Mydb.dbReset(102)
END IF
MyDb.dbColor = "2,auto,lightblue"
MyDb.dbMode = "both" ' Want both Grid
MyDb.dbGridTableTag="BORDER=3" ' Set table border=3
MyDb.dbImageDir = "../images/" ' Point to the Nav. icons
MyDb.dbGridDisplayFlds = "1, 2, 3, 4"
MyDb.dbNavigation="top" ' Display it at the bottom only
MyDb.dbNavigationItem="top,prev,next,bottom,re load,color" ' Define which buttons
MyDB.dbNavigationIcon = "std"
MyDB.dbGridInc = 10
MyDb.dbNameMap = "cat_name,Category;problem,Problem;type_name,T ype;last_name,Submitter"
MyDb.dbGridTableTag = "BORDER=3 CELLPADDING=3 CELLSPACING=3" ' Specify our Grid Table Tags
x1 = "Problem, width=420,<A HREF=""single_entry.asp?ID=#ID#""> #Problem#</A>;"
x1 = x1 + "type_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#type_name# </FONT>;"
x1 = x1 + "cat_name,Align=center width=130, <FONT FACE='Arial' SIZE='2' COLOR='black'>#cat_name# </FONT>;"
x1 = x1 + "last_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#last_name# </FONT>;"
MyDb.dbMagicCell = x1
MyDb.dbGridIndexLink = False
MyDb.dbSQL = SQL
MyDb.ASPdbpro ' Show the Database now!
'redirect back to the search engine page
'If MyDb.dbRecordCount = 0 then
' Response.Clear
' Response.Redirect "redirect.asp"
' Response.End
'End If
'End if
%>
<div align="center">
<FORM>
<input type="button" value="Search Again?" Onclick="again()">
<input type="button" value="Home" name="Home" OnClick="visitSite()"
</form>
</div>
</BODY>
</HTML>
-
dbreset? (reply)
Paul,
It is unlikely that anybody can help you with your particular appplication in a forum environment. If you want to solicit help then you shoul dpost "clean" and code using a common database like Northwind/Pubs/EMP or ACCESS, SQL and ORACLE. However, a quick look at your code tells me that you are changing the SQL dynamically w/o the correct reset. One expensive way is to use a different Unit number when using a different SQL. Otherwise, study the following code and see whether it helps...
<%
change=false
if request.form("which"="1" then
session("DB"="employees"
change=true
end if
if request.form("which"="2" then
session("DB"="orders"
change=true
end if
if session("DB"="" then session("DB"="employees"
response.write(request.form)
Set X= Server.CreateObject("ASPdb.Y2K"
X.dbUnit = 999
if change then X.dbreset(999)
X.dbDSN = "DSN=NWIND"
X.dbSQL = "SELECT * FROM " & session("DB"
X.ASPdbY2K
%>
<FORM ACTION="DB12.asp" METHOD="POST">
<INPUT TYPE="Text" NAME="WHICH">
<INPUT TYPE="Submit">
</FORM>
FK
------------
Paul at 5/10/00 11:57:55 AM
Here is the jist of my problem.
I have constructed my own search engine and it gives the user the option of filtering the data. If a search comes back with more than 10 records, clicking on the Next button does not give the correct results. Pressing the Previous button doesn't come close to getting the original results returned. I have used many variations of the dbreset w/o any luck. Below I have included the code for the results. The '*** comments are about the dbreset code tried. What I am I doing wrong?? Thanks in advance.
<% @ Language=VBScript %>
<!-- #include file="../../includethis.inc"-->
<% checkcookee() %>
<% Response.Buffer = True %>
<!-- * Page Function - Display Search Results in Table * -->
<HTML>
<HEAD>
<TITLE>Search Results</TITLE></HEAD>
<SCRIPT LANGUAGE="JavaScript">
function again() {
document.location="search.asp"
}
function visitSite() {
document.location="../default.asp"
}
</SCRIPT>
</HEAD>
<BODY ALINK="Red" VLINK="Navy" LINK="Blue" bgcolor="White">
<div align="center"><h2>Query Results</h2></div>
<hr>
<%
Session( "searchword" ) = request.form("searchword"
Session( "searchword1" ) = request.form("searchword1"
Session( "cat" ) = request.form("category"
Session( "type1" ) = request.form("testtype"
Session( "person" ) = request.form("username"
' *** from the dbreset example -using this made the Next button display nothing
'If (Session( "searchword" ) <> "" Or Session( "searchword1" ) <> "" Or Session( "cat" ) <> "" Or Session( "type1" ) <> "" Or Session( "person" ) <> "" ) then
' Create the ASP-db object:
Set MyDb = Server.CreateObject("ASPdb.Pro"
' Use YourFile.mdb in the current directory:
MyDb.dbDSN = "K_base"
MyDb.dbUnit=102
SQL = "Select main.id, main.problem, type.type_name, category.cat_name, employees.last_name FROM Main, Type, Category, Employees WHERE ("
If (Session( "searchword" ) <> "" ) then
SQL = SQL + " main.problem Like '%" + Session( "searchword" ) + "%' AND"
End If
If (Session( "searchword1" ) <> "" ) then
SQL = SQL + " main.symptoms Like '%" + Session( "searchword1" ) + "%' AND"
End If
If (Session( "cat" ) <> "" ) then
SQL = SQL + " main.category = " + Session( "cat" ) + " AND"
End If
If (Session( "type1" ) <> "" ) then
SQL = SQL + " main.type = " + Session( "type1" ) + " AND"
End If
If (Session( "person" ) <> "" ) then
SQL = SQL + " main.username = " + Session( "person" ) + " AND"
End If
SQL = SQL + " main.type = type.type_id AND main.category = category.cat_id AND main.username = employees.emp_id "
SQL = SQL + ""
' ***** from the dbreset example
If (request.form("searchword" <> "" Or request.form("searchword1" <> "" Or request.form("category" <> "" Or request.form("testtype" <> "" Or request.form("username" <> "" ) then
Mydb.dbReset(102)
END IF
MyDb.dbColor = "2,auto,lightblue"
MyDb.dbMode = "both" ' Want both Grid
MyDb.dbGridTableTag="BORDER=3" ' Set table border=3
MyDb.dbImageDir = "../images/" ' Point to the Nav. icons
MyDb.dbGridDisplayFlds = "1, 2, 3, 4"
MyDb.dbNavigation="top" ' Display it at the bottom only
MyDb.dbNavigationItem="top,prev,next,bottom,re load,color" ' Define which buttons
MyDB.dbNavigationIcon = "std"
MyDB.dbGridInc = 10
MyDb.dbNameMap = "cat_name,Category;problem,Problem;type_name,T ype;last_name,Submitter"
MyDb.dbGridTableTag = "BORDER=3 CELLPADDING=3 CELLSPACING=3" ' Specify our Grid Table Tags
x1 = "Problem, width=420,<A HREF=""single_entry.asp?ID=#ID#""> #Problem#</A>;"
x1 = x1 + "type_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#type_name# </FONT>;"
x1 = x1 + "cat_name,Align=center width=130, <FONT FACE='Arial' SIZE='2' COLOR='black'>#cat_name# </FONT>;"
x1 = x1 + "last_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#last_name# </FONT>;"
MyDb.dbMagicCell = x1
MyDb.dbGridIndexLink = False
MyDb.dbSQL = SQL
MyDb.ASPdbpro ' Show the Database now!
'redirect back to the search engine page
'If MyDb.dbRecordCount = 0 then
' Response.Clear
' Response.Redirect "redirect.asp"
' Response.End
'End If
'End if
%>
<div align="center">
<FORM>
<input type="button" value="Search Again?" Onclick="again()">
<input type="button" value="Home" name="Home" OnClick="visitSite()"
</form>
</div>
</BODY>
</HTML>
-
dbreset? (reply)
Frank,
Is the SQL statement being run all over again when the Next button is activated to get the 11-20 records?
Paul
------------
Frank at 5/10/00 4:32:45 PM
Paul,
It is unlikely that anybody can help you with your particular appplication in a forum environment. If you want to solicit help then you shoul dpost "clean" and code using a common database like Northwind/Pubs/EMP or ACCESS, SQL and ORACLE. However, a quick look at your code tells me that you are changing the SQL dynamically w/o the correct reset. One expensive way is to use a different Unit number when using a different SQL. Otherwise, study the following code and see whether it helps...
<%
change=false
if request.form("which"="1" then
session("DB"="employees"
change=true
end if
if request.form("which"="2" then
session("DB"="orders"
change=true
end if
if session("DB"="" then session("DB"="employees"
response.write(request.form)
Set X= Server.CreateObject("ASPdb.Y2K"
X.dbUnit = 999
if change then X.dbreset(999)
X.dbDSN = "DSN=NWIND"
X.dbSQL = "SELECT * FROM " & session("DB"
X.ASPdbY2K
%>
<FORM ACTION="DB12.asp" METHOD="POST">
<INPUT TYPE="Text" NAME="WHICH">
<INPUT TYPE="Submit">
</FORM>
FK
------------
Paul at 5/10/00 11:57:55 AM
Here is the jist of my problem.
I have constructed my own search engine and it gives the user the option of filtering the data. If a search comes back with more than 10 records, clicking on the Next button does not give the correct results. Pressing the Previous button doesn't come close to getting the original results returned. I have used many variations of the dbreset w/o any luck. Below I have included the code for the results. The '*** comments are about the dbreset code tried. What I am I doing wrong?? Thanks in advance.
<% @ Language=VBScript %>
<!-- #include file="../../includethis.inc"-->
<% checkcookee() %>
<% Response.Buffer = True %>
<!-- * Page Function - Display Search Results in Table * -->
<HTML>
<HEAD>
<TITLE>Search Results</TITLE></HEAD>
<SCRIPT LANGUAGE="JavaScript">
function again() {
document.location="search.asp"
}
function visitSite() {
document.location="../default.asp"
}
</SCRIPT>
</HEAD>
<BODY ALINK="Red" VLINK="Navy" LINK="Blue" bgcolor="White">
<div align="center"><h2>Query Results</h2></div>
<hr>
<%
Session( "searchword" ) = request.form("searchword"
Session( "searchword1" ) = request.form("searchword1"
Session( "cat" ) = request.form("category"
Session( "type1" ) = request.form("testtype"
Session( "person" ) = request.form("username"
' *** from the dbreset example -using this made the Next button display nothing
'If (Session( "searchword" ) <> "" Or Session( "searchword1" ) <> "" Or Session( "cat" ) <> "" Or Session( "type1" ) <> "" Or Session( "person" ) <> "" ) then
' Create the ASP-db object:
Set MyDb = Server.CreateObject("ASPdb.Pro"
' Use YourFile.mdb in the current directory:
MyDb.dbDSN = "K_base"
MyDb.dbUnit=102
SQL = "Select main.id, main.problem, type.type_name, category.cat_name, employees.last_name FROM Main, Type, Category, Employees WHERE ("
If (Session( "searchword" ) <> "" ) then
SQL = SQL + " main.problem Like '%" + Session( "searchword" ) + "%' AND"
End If
If (Session( "searchword1" ) <> "" ) then
SQL = SQL + " main.symptoms Like '%" + Session( "searchword1" ) + "%' AND"
End If
If (Session( "cat" ) <> "" ) then
SQL = SQL + " main.category = " + Session( "cat" ) + " AND"
End If
If (Session( "type1" ) <> "" ) then
SQL = SQL + " main.type = " + Session( "type1" ) + " AND"
End If
If (Session( "person" ) <> "" ) then
SQL = SQL + " main.username = " + Session( "person" ) + " AND"
End If
SQL = SQL + " main.type = type.type_id AND main.category = category.cat_id AND main.username = employees.emp_id "
SQL = SQL + ""
' ***** from the dbreset example
If (request.form("searchword" <> "" Or request.form("searchword1" <> "" Or request.form("category" <> "" Or request.form("testtype" <> "" Or request.form("username" <> "" ) then
Mydb.dbReset(102)
END IF
MyDb.dbColor = "2,auto,lightblue"
MyDb.dbMode = "both" ' Want both Grid
MyDb.dbGridTableTag="BORDER=3" ' Set table border=3
MyDb.dbImageDir = "../images/" ' Point to the Nav. icons
MyDb.dbGridDisplayFlds = "1, 2, 3, 4"
MyDb.dbNavigation="top" ' Display it at the bottom only
MyDb.dbNavigationItem="top,prev,next,bottom,re load,color" ' Define which buttons
MyDB.dbNavigationIcon = "std"
MyDB.dbGridInc = 10
MyDb.dbNameMap = "cat_name,Category;problem,Problem;type_name,T ype;last_name,Submitter"
MyDb.dbGridTableTag = "BORDER=3 CELLPADDING=3 CELLSPACING=3" ' Specify our Grid Table Tags
x1 = "Problem, width=420,<A HREF=""single_entry.asp?ID=#ID#""> #Problem#</A>;"
x1 = x1 + "type_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#type_name# </FONT>;"
x1 = x1 + "cat_name,Align=center width=130, <FONT FACE='Arial' SIZE='2' COLOR='black'>#cat_name# </FONT>;"
x1 = x1 + "last_name,Align=center width=60, <FONT FACE='Arial' SIZE='2' COLOR='black'>#last_name# </FONT>;"
MyDb.dbMagicCell = x1
MyDb.dbGridIndexLink = False
MyDb.dbSQL = SQL
MyDb.ASPdbpro ' Show the Database now!
'redirect back to the search engine page
'If MyDb.dbRecordCount = 0 then
' Response.Clear
' Response.Redirect "redirect.asp"
' Response.End
'End If
'End if
%>
<div align="center">
<FORM>
<input type="button" value="Search Again?" Onclick="again()">
<input type="button" value="Home" name="Home" OnClick="visitSite()"
</form>
</div>
</BODY>
</HTML>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|