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 > please help with connection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-11-06, 10:01
poison_chicken poison_chicken is offline
Registered User
 
Join Date: Feb 2006
Posts: 34
please help with connection

i have the following code,

strLoginID = request("loginID")
Set rsPart = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM Login WHERE loginID = " & strLoginID
rsPart.Open sql, conn1, 2, 3

everything works fine when typing a number like 123 in the textbox, but if i type abc, i get the error
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Reply With Quote
  #2 (permalink)  
Old 05-11-06, 15:43
csamuels csamuels is offline
Registered User
 
Join Date: Mar 2006
Location: south jersey, usa
Posts: 53
put single quotes around the loginid. use single quotes in sql queries whenever referencing strings.

sql = "SELECT * FROM Login WHERE loginID = '" & strLoginID & "'"
__________________
"They say Moses split the Red Sea
I split the blunt and rolled the fat one, I'm deadly"
-- Tupac 'Blasphemy'
Reply With Quote
  #3 (permalink)  
Old 05-12-06, 10:36
poison_chicken poison_chicken is offline
Registered User
 
Join Date: Feb 2006
Posts: 34
oh snap

i am still getting an error. i think the problem is in my data types. the data type in the sql table is a number.

so to recap, if "123" (without quotes) is typed at login box, i convert to a string to for the sql string. but if "abc" is typed in, i get an error (even with the extra quotes such as in the message above, ' " & strLoginID "'", but with the extra quotes, number entries don't work then).

should i change my data type in the table?
Reply With Quote
  #4 (permalink)  
Old 05-12-06, 12:52
csamuels csamuels is offline
Registered User
 
Join Date: Mar 2006
Location: south jersey, usa
Posts: 53
if you want the loginids to be able to contain letters, then change the datatype. I suggest text. After the change, you should have any problems using the single quotes as they will be required.
__________________
"They say Moses split the Red Sea
I split the blunt and rolled the fat one, I'm deadly"
-- Tupac 'Blasphemy'
Reply With Quote
  #5 (permalink)  
Old 05-12-06, 13:45
poison_chicken poison_chicken is offline
Registered User
 
Join Date: Feb 2006
Posts: 34
i think i will keep it as a number, the loginIDs are pre-assigned to be numbers and they (users) will not have an opportunity to change there ID (this is a one-time login...or actually as many times in a 2-week period login for a survey). however, i will want to handle the error of someone accidently typing letters so as not to get the server side error message. can that be done in MS sql or should i handle it in the asp?
lastly (for now)...are there "standards" for assigning datatypes? i remember reading that it is standard to use "text" for SS#. are there hidden (to me) benefits of using "text" rather than number for various datatypes. Where can i learn more of basic conventions for assigning datatypes.
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