www.webdeveloper.com
Results 1 to 6 of 6

Thread: Web DB Problem

  1. #1
    Join Date
    Feb 2003
    Posts
    15

    Exclamation 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:\dsn\TestDB_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.

  2. #2
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    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") & "'"
    ----------------------------------

  3. #3
    Join Date
    Feb 2003
    Posts
    15
    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?firstCh...hirdChoice=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;
    I am novice to this and hope this is makes my problem a bit clearer.

  4. #4
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    did you try it with OR instead of AND?
    ----------------------------------

  5. #5
    Join Date
    Feb 2003
    Posts
    15
    Yeah i tried it and it just returned the same result - nothing from the DB!

  6. #6
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    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 "
    ----------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles