Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006
    Posts
    34

    Unanswered: 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.

  2. #2
    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'

  3. #3
    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?

  4. #4
    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'

  5. #5
    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.

Posting Permissions

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