Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL select query
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL select query

 Post Reply Post Reply
Author
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Topic: SQL select query
    Posted: 07 November 2003 at 3:47am

Hi,

I know I'm doing something wrong, but I don't know what.

Basically I have 1 file where the user selects which username to amend and then they are passed to this file, the username field is the primary key in the database.

I get the following error msg:-

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/revcontrol/prs/useradmin/edit.asp, line 20

I have the following code:-

<%
dim conn, rs, strconn

strconn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database/prs.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs = conn.Execute("SELECT * FROM users WHERE username=" &Request("username")) <---- This is line 20
%>

Can somebody point me in the right direction, as I know I missing something....

TIA

Steve

Back to Top
svpworld View Drop Down
Groupie
Groupie


Joined: 06 March 2003
Location: usa
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote svpworld Quote  Post ReplyReply Direct Link To This Post Posted: 07 November 2003 at 5:11am

Where does Request("username") come from?  Does it contain anything?  and maybe you need to terminate the SQL statement with a semicolon, at least in SQL server you do.

Simon

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 07 November 2003 at 5:16am

Turn:
set rs = conn.Execute("SELECT * FROM users WHERE username=" &Request("username"))

Into (changes in blue):
set rs = conn.Execute("SELECT * FROM users WHERE username= '" & Request("username") & "'")

(and yes, using fonts on posts that can actually be read help people help you better)

also you may want to look into "SQL Injection" (search that term on google) and hopefully it makes sense... with that code you posted, an amature hacker could get full access to your database with that code you posted

Contribute to the working anarchy we fondly call the Internet
Back to Top
stevem2003 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 November 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevem2003 Quote  Post ReplyReply Direct Link To This Post Posted: 07 November 2003 at 6:22am

Many thanks MorningZ, works a treat

also noted about the fonts

 

Back to Top
PeterE View Drop Down
Newbie
Newbie
Avatar

Joined: 05 November 2003
Location: Netherlands
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote PeterE Quote  Post ReplyReply Direct Link To This Post Posted: 08 November 2003 at 4:20am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.