Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi, thanks for the reply.

 

About reading and comparing from dataset/datatable, could you elaborate more or provide a simple sample?

Posted
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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...