943,722 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 747
  • MS SQL RSS
Aug 17th, 2009
0

how can i get the column values

Expand Post »
hi,
i need to get the column values from the table login.it contais two columns ,userid and password. i want to check the userid and password values when the user logged in.so i have to compare the entered textbox value with the saved value. i am using the code is shown below.

MS SQL Syntax (Toggle Plain Text)
  1. rdr=cmd.executereader();
  2. while(rdr.READ())
  3. {
  4. IF(txtbox1.text==rdr[0])
  5. IF(txtbox2.text==rdr[0])
  6. msg(" successfully loggedin");
  7. }
i am using the asp.net(C#.net )with sql server..
so can u tell me the solution for that.
Last edited by peter_budo; Aug 17th, 2009 at 4:45 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 7
Solved Threads: 0
Junior Poster in Training
mohankumar554 is offline Offline
55 posts
since May 2009
Aug 17th, 2009
1

Re: how can i get the column values

Why dont you include the parameters in the select statement something like
MS SQL Syntax (Toggle Plain Text)
  1. string st = "select user, pass from loggin where user = '"+txtbox1.text+"' and pass = '"+txtbox2.text+"'";
  2. //Then pass that SELECT TO the command object
  3. rdr=cmd.executereader();
  4. IF(rdr.HasRows)
  5. {
  6. msg(" successfully loggedin");
  7. }

Take care.
Reputation Points: 56
Solved Threads: 56
Posting Pro in Training
jbisono is offline Offline
432 posts
since May 2009
Aug 18th, 2009
0

Re: how can match the userid and password with signed userid and pwd

hi,
thank you very much. ur code is working.. but i need to compare the userid and password with the saved user id and password in the database. when the both are matched then we will give the msg box as" successfully loggedin" . so can u send the code for it.
Reputation Points: 7
Solved Threads: 0
Junior Poster in Training
mohankumar554 is offline Offline
55 posts
since May 2009
Aug 18th, 2009
0

Re: how can i get the column values

You do not want to bring the password back in a select statement for security reasons. Do what jbisono suggested and send the data to the database. If you try to select the user "Where username = @username and password = @password" then it will return 0 rows since the password did not match, thus the login failed. If you have a row then the login was OK.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: sql stored procedure rounding off?
Next Thread in MS SQL Forum Timeline: Website Form -> SQL Database injection help/guide?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC