Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 27th, 2007, 05:04 AM
Registered User
Join Date: Feb 2007
Location: Jsrsey City, NJ, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing function parameter to query


     I am creating a class file which has a function of authenticating user. It connects to database and check password verification according to the username. But the variable I use as parameter which is "username"
how to pass that value to select query . code is as below.

public Boolean AuthenticateUser(string username, string password)
        String ConStr = ("Data Source=localhost;Initial Catalog=test;user ID = sa ;Password = keyur");
        String SQL = " SELECT Password from LoginInfo WHERE UserName = '" & username & "'

        SqlConnection conn = new SqlConnection(ConStr);
        SqlCommand cmd = new SqlCommand(SQL, conn);
        String var = null;
        var = (String)cmd.ExecuteScalar();

Web Developer
Reply With Quote
  #2 (permalink)  
Old February 27th, 2007, 08:28 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

It looks like you are coding in java. Why don't you use VBA? Anyway, without getting into java, this:

" SELECT Password from LoginInfo WHERE UserName = '" & username & "'

should be this:

"SELECT Password from LoginInfo WHERE UserName = '" & username & "'"

Did that help?

Reply With Quote

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing a parameter to an Access query! pankaj_daga Access VBA 6 November 16th, 2007 12:26 PM
Passing an Input Field to a Parameter Query stcraig BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 November 6th, 2006 06:06 PM
passing parameter to query vladimir Access 6 August 30th, 2006 05:39 AM
SQL query dropping parameter function... JackNimble Access 2 March 14th, 2005 04:56 PM
Passing parameter to Access query eapsokha Classic ASP Databases 2 September 16th, 2004 02:49 AM

All times are GMT -4. The time now is 08:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.