If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Query and textbox difficulty.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-05, 16:22
JJ7AS JJ7AS is offline
Registered User
 
Join Date: Jan 2005
Posts: 9
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
Reply With Quote
  #2 (permalink)  
Old 02-26-05, 20:30
gyuan gyuan is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 03-02-05, 19:38
Bullschmidt Bullschmidt is offline
Guru
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On