LiLo Posted June 6, 2006 Posted June 6, 2006 Hi, I am making a login web service. First a database is created. It has ID,username and password attributes. I plan to use the SELECT statement to retrieve the user record from the database. How do I enable the ASP.Net code to check the password attribute value returned by the SELECT statement? And if there is no record found, what value does the SELECT statement return and how to make ASP.Net know about this value? Quote
Administrators PlausiblyDamp Posted June 6, 2006 Administrators Posted June 6, 2006 If you are Querying the DB then you could just use a select statement to retreive the columns from the DB and put the result into either a DataReader or a DataTable - a DataReader is probably the simplest way in this case though. If there are no matching results then you will either have a DataTable with no records in it or a DataReader with no data. Also how are you storing the password? As a rule you should hash the password and store that rather than putting plain text into the DB. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
LiLo Posted June 7, 2006 Author Posted June 7, 2006 Hi, thanks for the reply. About reading and comparing from dataset/datatable, could you elaborate more or provide a simple sample? Quote
Arch4ngel Posted June 7, 2006 Posted June 7, 2006 Dim sqlconn as new SqlConnection(ConnectionString) Dim sqlcomm as SqlCommand = sqlconn.CreateCommand() sqlcomm.CommandText = "your sql query" sqlcomm.CommandType = CommandType.Text sqlcomm.Parameters.Add("@username", SqlDbType.VarChar, 50) sqlcomm.Parameters("@username").Value = username sqlconn.Open() Dim dr as SqlDataReader = sqlcomm.ExecuteReader() If dr.HasRows Then dr.Read If username=dr("username") and password=dr("password") then UserIsAuth(something) End If End If Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.