Checking for a value in Database?

Checking for a value in Database?

Old forum URL: forums.lhotka.net/forums/t/3302.aspx


reagan123 posted on Tuesday, July 31, 2007

Hi everyone.

Quick question... What is the best way to check and see if a users input exists in a database.

I.E:  After a user enters his username, I want to see if that username exists in my "user" table.  Is my best bet to fetch an info list and then loop through the list checking for that value or is there a better way?

I appeciate any help... i'm still new to the framework.


Thanks!

 

Public Function ValidateUser(ByVal userName As String) As Boolean

Try

Dim
userlist As UserInfoList
userlist = UserInfoList.GetUserInfoList()

For Each ui As UserInfo In userlist 
      If ui.UserName.ToLower.CompareTo(userName.ToLower()) = 0 Then
               
Return True
               
Exit For

      End If
Next

Catch ex As Exception

      Throw New SecurityException("Unable to find user", ex)

End Try

End Function

RockfordLhotka replied on Tuesday, July 31, 2007

http://forums.lhotka.net/forums/post/3273.aspx

reagan123 replied on Tuesday, July 31, 2007

Thanks so much for the link Rocky.  I'll go give it a shot.  I'm still in the process of learning the framework.

I appreciate the help.

Copyright (c) Marimer LLC