•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,203 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,195 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1319 | Replies: 5 | Solved
![]() |
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 2
Solved Threads: 0
Hi guys!
I was wondering if any of you guys would be able to help solve what is probably a simple problem....
I am using dreamweaver / asp/ access to create a dynamic web application. I have created a record set which queries the database and displays the results. The recordset searches for a product id which is inserted by the user, the product details are then displayed. I somehow can only get the first record in the database to display in the dynamic table. This record is not even searched for it is just there already when i preview the page in the browser then when I enter another ID nothing happens.
here is my code :-
Any ideas would be greatly appreciated! Thanks!!!
GLT
I was wondering if any of you guys would be able to help solve what is probably a simple problem....
I am using dreamweaver / asp/ access to create a dynamic web application. I have created a record set which queries the database and displays the results. The recordset searches for a product id which is inserted by the user, the product details are then displayed. I somehow can only get the first record in the database to display in the dynamic table. This record is not even searched for it is just there already when i preview the page in the browser then when I enter another ID nothing happens.
here is my code :-
asp Syntax (Toggle Plain Text)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/dbtest.asp" --> <% Dim rs_search__MMColParam rs_search__MMColParam = "1" If (Request.Form("ProductID") <> "") Then rs_search__MMColParam = Request.Form("ProductID") End If %> <% Dim rs_search Dim rs_search_numRows Set rs_search = Server.CreateObject("ADODB.Recordset") rs_search.ActiveConnection = MM_dbtest_STRING rs_search.Source = "SELECT * FROM product WHERE ProductID = " + Replace(rs_search__MMColParam, "'", "''") + " ORDER BY ProductID ASC" rs_search.CursorType = 0 rs_search.CursorLocation = 2 rs_search.LockType = 1 rs_search.Open() rs_search_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = 10 Repeat1__index = 0 rs_search_numRows = rs_search_numRows + Repeat1__numRows %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>search</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body>Insert product ID you wish to search for:- <form method="POST" name="formsearch" id="formsearch"> <table width="528" height="136" border="1"> <tr> <td width="153">productID</td> <td width="359"><input name="txtProductID" type="text" id="txtProductID" size="50"></td> <td><input name="btnsearch" type="submit" id="btnsearch" value="search"></td> </tr> </table> <input type="hidden" name="MM_search" value="formsearch"> </form> <p> </p> <table border="1"> <tr> <td>ProductID</td> <td>Product</td> <td>Price</td> </tr> <% While ((Repeat1__numRows <> 0) AND (NOT rs_search.EOF)) %> <tr> <td><%=(rs_search.Fields.Item("ProductID").Value)%></td> <td><%=(rs_search.Fields.Item("Product").Value)%></td> <td><%= FormatCurrency((rs_search.Fields.Item("Price").Value), 2, -2, -2, -2) %></td> </tr> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 rs_search.MoveNext() Wend %> </table> </body> </html> <% rs_search.Close() Set rs_search = Nothing %>
Any ideas would be greatly appreciated! Thanks!!!

GLT
Last edited by peter_budo : Mar 27th, 2008 at 2:42 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 2
Solved Threads: 0
It seems to be that my default value in the recordset is set to '1' , I changed this to '0' and it said 'no data', this is because there is not product with the Id of 0. All i want to do is search for an ID and then it is displayed to the user not just what is in the default value. I have tried not putting anything in the default value and Dreamweaver wont let me.
Any ideas???
Any ideas???
•
•
Join Date: Feb 2008
Posts: 135
Reputation:
Rep Power: 1
Solved Threads: 3
Try to close the variable with a single quote 'rs_search__MMColParam = "1" and test. It is set to the static value "1" for some reason. It is possible that value overrides the input.
Test this:
.... or try to contain the variable within the (If then).
Another option that maybe solve the thing is to change the name to txtProductID
Test this:
Dim rs_search__MMColParam
'rs_search__MMColParam = "1"
If (Request.Form("ProductID") <> "") Then
rs_search__MMColParam = Request.Form("ProductID")
End If.... or try to contain the variable within the (If then).
Dim rs_search__MMColParam
If (Request.Form("ProductID") <> "") Then
rs_search__MMColParam = Request.Form("ProductID")
ElseIf (Request.Form("ProductID") = "") Then
rs_search__MMColParam = "1"
End IfAnother option that maybe solve the thing is to change the name to txtProductID
Dim rs_search__MMColParam
rs_search__MMColParam = "1"
If (Request.Form("txtProductID") <> "") Then
rs_search__MMColParam = Request.Form("txtProductID")
End If Last edited by TobbeK : Mar 18th, 2008 at 8:51 pm.
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 2
Solved Threads: 0
I still cant get it to work.
I think its because I have a default value of 1 but i have to put something into the default value so what should i do??
all i want to do is create a simple search and results page, the user will enter an id and the details are displayed.
any ideas would be greatly apprieciated!
Thanks!
GLT
I think its because I have a default value of 1 but i have to put something into the default value so what should i do??
all i want to do is create a simple search and results page, the user will enter an id and the details are displayed.
any ideas would be greatly apprieciated!
Thanks!
GLT
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 2
Solved Threads: 0
this is the code i have at the minute:-
asp Syntax (Toggle Plain Text)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/dbtest.asp" --> <% Dim rs_search__MMColParam If (Request.Form("ProductID") <> "") Then rs_search__MMColParam = Request.Form("ProductID") ElseIf (Request.Form("ProductID") = "") Then rs_search__MMColParam = "1" End If %> <% Dim rs_search Dim rs_search_numRows Set rs_search = Server.CreateObject("ADODB.Recordset") rs_search.ActiveConnection = MM_dbtest_STRING rs_search.Source = "SELECT * FROM product WHERE ProductID = " + Replace(rs_search__MMColParam, "'", "''") + " ORDER BY ProductID ASC" rs_search.CursorType = 0 rs_search.CursorLocation = 2 rs_search.LockType = 1 rs_search.Open() rs_search_numRows = 0 %> <% Dim Repeat1__numRows Dim Repeat1__index Repeat1__numRows = 10 Repeat1__index = 0 rs_search_numRows = rs_search_numRows + Repeat1__numRows %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>search</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body>Insert product ID you wish to search for:- <form method="POST" name="formsearch" id="formsearch"> <table width="528" height="136" border="1"> <tr> <td width="153">productID</td> <td width="359"><input name="txtProductID" type="text" id="txtProductID" size="50"></td> <td><input name="btnsearch" type="submit" id="btnsearch" value="search"></td> </tr> </table> <input type="hidden" name="MM_search" value="formsearch"> </form> <p> </p> <p>results:-</p> <table border="1"> <tr> <td width="87">ProductID</td> <td width="87">Product</td> <td width="87">Price</td> </tr> <% While ((Repeat1__numRows <> 0) AND (NOT rs_search.EOF)) %> <tr> <td><%=(rs_search.Fields.Item("ProductID").Value)%></td> <td><%=(rs_search.Fields.Item("Product").Value)%></td> <td><%=(rs_search.Fields.Item("Price").Value)%></td> </tr> <% Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 rs_search.MoveNext() Wend %> </table> </body> </html> <% rs_search.Close() Set rs_search = Nothing %>
Last edited by peter_budo : Mar 27th, 2008 at 2:42 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Aug 2007
Posts: 98
Reputation:
Rep Power: 2
Solved Threads: 0
I solved it myself! It was my fault!
I had to change the code to point to the text box in the search form not the field in the database table! I didnt realise it was doing this as they are both called the same except the text box is called txtProductID not ProductID.
Here is the new code for the section i changed:-
Thanks for you help!!
GLT
I had to change the code to point to the text box in the search form not the field in the database table! I didnt realise it was doing this as they are both called the same except the text box is called txtProductID not ProductID.
Here is the new code for the section i changed:-
asp Syntax (Toggle Plain Text)
Dim rs_search__MMColParam rs_search__MMColParam = "1" If (Request.Form("txtProductID") <> "") Then rs_search__MMColParam = Request.Form("txtProductID") End If
Thanks for you help!!
GLT
Last edited by peter_budo : Mar 27th, 2008 at 2:42 am. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice breach broadband business code combo crime cult of the dead cow daniweb data data protection data transfer database dreamweaver drive dropdownlist encryption europe forensic forensics fun google government hacking hard hardware help hitachi hp html industrial espionage it linux module net news payment services privacy protection reuse search security storage terabyte tv web wikipedia wysiwyg
- Previous Thread: Restrict Access to page.
- Next Thread: windows server 2003 service pack 2


Linear Mode