Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    9

    Unanswered: Query and textbox difficulty.

    Can anyone help please? On a login page i have constructed, u can login (if ur registered) by entering your surname and postcode. Once logged in i would like a welcome note to display the Customer_Name on the Customer homepage. If i use the following statement would it find the items in the specified text boxes and print the correct name?


    RsCUSTOMER.open "Select Customer_Name from CUSTOMER WHERE Customer_Surname = the value in the text box AND Customer_PostCode = the value in the text box", Conn

    <%Response.write("Welcome" & rsCUSTOMER("Customer_Name")%>

    Any help would be much appreciated.
    Regards, John

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    I think that your code should be working. Did you try it? Since the combination of customer surname and postcode is not unique, the record set may contain more than one row of data.

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    If the underlying database fields are text instead of number then you need single quotes too:

    RsCUSTOMER.open "Select Customer_Name from CUSTOMER WHERE Customer_Surname = 'the value in the text box' AND Customer_PostCode = 'the value in the text box'", Conn

    And with actual variables might look like:

    RsCUSTOMER.open "Select Customer_Name from CUSTOMER WHERE Customer_Surname = '" & TheTextboxVariable & "' AND Customer_PostCode = '" & TheOtherTextboxVariable & "'", Conn

    And of course hope there aren't any single quotes in the last name or postal code or else you'd want to double those up which is probably a good idea anyways as you never know:

    RsCUSTOMER.open "Select Customer_Name from CUSTOMER WHERE Customer_Surname = '" & Replace(TheTextboxVariable, "'", "''") & "' AND Customer_PostCode = '" & Replace(TheOtherTextboxVariable, "'", "''") & "'", Conn
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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