View Single Post
Join Date: Oct 2007
Posts: 1
Reputation: glfoster is an unknown quantity at this point 
Solved Threads: 0
glfoster glfoster is offline Offline
Newbie Poster

Re: Help me in username and password validation through accessing the database

 
0
  #3
Oct 27th, 2007
Hello,

I am trying to do something similar against a SQL server database with a user database already up and running.

The code below connects to the SQL server with no problems and returns the number of users that match the criteria.

My problem arises when I want to do a simple comprison against the result. How do I access the "NUM_OF_USERS" value for comparison?

I have this same issue with another part of the project where I can pull data from the DB but I can't access the individual parts to perform formattin and conputations on them.

If there is a better method for completing this I am open to input! :-)

  1. Function DBConnection(ByVal strUserName As String, ByVal strPassword As String) As Boolean
  2.  
  3. Try
  4.  
  5. SqlDataSource1.ConnectionString = MyConn.ConnectionString
  6.  
  7. SqlDataSource1.SelectCommand = "SELECT COUNT(*) AS Num_of_User FROM PID WHERE (PID = '" & strUserName & "') AND (PASSWORD = '" & strPassword & "');"
  8.  
  9. 'If count = 1 Then
  10. 'Return True
  11. 'Else
  12. 'Return False
  13. 'End If
  14.  
  15. Catch ex As Exception
  16.  
  17. lblMessage.Text = "Error Connecting to Database!"
  18.  
  19. End Try
  20.  
  21. End Function
Reply With Quote