/    Sign up×
Community /Pin to ProfileBookmark

Web DB Problem

I am currently in the process of designing a small DB-driven website.

This website has a search function on the front page which allows users to select menus. i.e. The user selects from menu 1, Flow CV, which then populates the 2nd menu, Orifice size, with only products corresponindg to this. The user then selects from this menu and the 3rd menu is populated. Finally they select from this and then submit to an ASP page.

I have created this search function using javascript and arrays, the following is an example of the array I have created:

var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[3] = “Orifice size A”;
arrItemsGrp1[3] = 1;
arrItems1[4] = “Orifice Size B”;
arrItemsGrp1[4] = 1;
arrItems1[5] = “Orifice Size C”;
arrItemsGrp1[5] = 1;

The ASP page takes the information from the drop down menus and searches the MS Access DB for the product, returning it to screen.

The following is some of the code in my asp page:
<%
‘build SQL statement – get from the MS Access DB all the details on the product selected in the drop-down menu

SQL_query = “SELECT * FROM products WHERE Flow_Cv = ‘” & Request.Form(“firstChoice”) & “‘ AND Orifice_size = ‘” & Request.Form(“secondChoice”) & “‘ AND Port_Connection = ‘” & Request.Form(“thirdChoice”) & “‘”

‘Create connection name “MyConn”
‘Load the resulting recordset into the variable RS

Set MyConn = Server.CreateObject(“ADODB.Connection”)
MyConn.Open “FILEDSN=c:dsnTestDB_dsn.dsn”

Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF

Response.Write “Product_id : ” & rs(“Product_id”) & ” “%> ——— Click here to BUY<BR><BR>

<%
RS.MoveNext
WEND
RS.Close
MyConn.Close
%>

My problem is, that the asp page is loading but not returning any results from the DB. Has anybody any ideas on the problem????

I will try to supply as much info as possible if you need it.

to post a comment
Full-stack Developer

5 Comments(s)

Copy linkTweet thisAlerts:
@RibeyedFeb 11.2003 — hi

try this:

SQL_query = "SELECT * FROM products WHERE Flow_Cv = '" & Request.Form("firstChoice") & "' OR Orifice_size = '" & Request.Form("secondChoice") & "' OR Port_Connection = '" & Request.Form("thirdChoice") & "'"
Copy linkTweet thisAlerts:
@Andy_1877authorFeb 11.2003 — It isnt the "AND" "OR" that are the problem. I need to have AND gates because each selection by the user has to be used to search the DB. there are matching records in the DB as well.

While I use the GET method I see that the url is

http://localhost/product.asp?firstChoice=1&secondChoice=3&thirdChoice=101

for my asp page.

I dont know why the numbers are being passed. I want the string to be passed and then searched upon using the sql statement.

This is an example of my array on the search page...When the user has selected one of these item (say orifice size A) I want the asp page to search the DB for that and the other two menu selections
arrItems1[3] = "Orifice size A";

arrItemsGrp1[3] = 1;

arrItems1[4] = "Orifice Size B";

arrItemsGrp1[4] = 1; [/QUOTE]


I am novice to this and hope this is makes my problem a bit clearer.
Copy linkTweet thisAlerts:
@RibeyedFeb 11.2003 — hi,

did you try it with OR instead of AND?
Copy linkTweet thisAlerts:
@Andy_1877authorFeb 11.2003 — Yeah i tried it and it just returned the same result - nothing from the DB!
Copy linkTweet thisAlerts:
@RibeyedFeb 11.2003 — hi,

try this:

SQL_query = "SELECT * FROM products " & _

" WHERE (Flow_Cv = '" & Request.Form("firstChoice") & "'" &_


" OR Orifice_size = '" & Request.Form("secondChoice") & "'" &_

" OR Port_Connection = '" & Request.Form("thirdChoice") & "')"&_


" GROUP BY " & _

" Flow_Cv "
×

Success!

Help @Andy_1877 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...