how can i get the column values

Reply

Join Date: May 2009
Posts: 52
Reputation: mohankumar554 is an unknown quantity at this point 
Solved Threads: 0
mohankumar554 mohankumar554 is offline Offline
Junior Poster in Training

how can i get the column values

 
0
  #1
Aug 17th, 2009
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.

  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.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 196
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 24
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: how can i get the column values

 
1
  #2
Aug 17th, 2009
Why dont you include the parameters in the select statement something like
  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.
If your already resolved your issue, flag it as solved.
José Bisonó
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 52
Reputation: mohankumar554 is an unknown quantity at this point 
Solved Threads: 0
mohankumar554 mohankumar554 is offline Offline
Junior Poster in Training

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

 
0
  #3
Aug 18th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,464
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 629
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: how can i get the column values

 
0
  #4
Aug 18th, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 487 | Replies: 3
Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC