SQL Query containing form value doesn't work

Results 1 to 3 of 3

Thread: SQL Query containing form value doesn't work

  1. #1
    Matthew Pritzker Guest

    Default SQL Query containing form value doesn't work

    I want to submit the following query:<BR>SELECT [SSN to NT login].SocialSecurityNumber<BR>FROM [SSN to NT login]<BR>WHERE ((([SSN to NT login].[NT Login])=::USERNAME::));<BR><BR>USERNAME is the name of a field on the previous page<BR>Before the SQL statement, I have<BR>&#060;%<BR>TrimmedUserName = CStr(Request("UserName"))<BR>%&#062;<BR>You are logged in as &#060;B&#062;&#060;%=TrimmedUserName%&#062;&#06 0;/B&#062;<BR><BR>which outputs the correct name to the screen.<BR><BR>Below it, though, I see:<BR>Database Results Error<BR>Description: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.<BR>Number: -2147217904 (0x80040E10)<BR>Source: Microsoft OLE DB Provider for ODBC Drivers<BR><BR>If it helps, server is IIS4.0, and my webpage editor is FrontPage2000 (4.0.2)<BR><BR>Any insight appreciated, and if you could Cc: to mpritzke@indiana.edu, that would be greatly appreciated.

  2. #2
    Response Guest

    Default RE: SQL Query containing form value doesn't wo

    Take your query string and put it in a response.write() command one line befor you execute the query. You will see that something is not showing up correctly. This is not the answer, but it will start you on your way to getting there.<BR><BR>One more thing. I would have written you where statement like this:<BR><BR>([SSN to NT login].[NT Login])=&#039"&USERNAME&"&#039"<BR><BR>with this line above the SQL<BR><BR>UserName = CStr(Request("UserName"))<BR><BR>Good Luck<BR>Brandon

  3. #3
    mark Guest

    Default RE: SQL Query containing form value doesn't wo

    Assuming USERNAME is a variable established on the active ASP page, Then Try:<BR><BR>SQL = "SELECT [SSN to NT login].SocialSecurityNumber "<BR>SQL = SQL & "FROM [SSN to NT login] "<BR>SQL = SQL & "WHERE [SSN to NT login].[NT Login]=&#039" & USERNAME & &#039 "<BR><BR>If USERNAME [NT login] is a text string, it must be inclosed in single quotes!<BR><BR>If USERNAME is a variable on a previous ASP page, you must pass the value of the previous page variable to the active page variable by using a querystring parameter, or a form field, or a cookie. You can only read variables that exist in page state, Session state, or Application state. You can not read page state variables from other asp pages.<BR>

Posting Permissions

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