Thread: DataBase Class
View Single Post
  #2 (permalink)  
Old July 29th, 2004, 11:35 AM
planoie's Avatar
planoie planoie is offline
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Usually when we say this we mean this:

Make a class that contains the logic to call the database and handle the various aspects of data manipulation. Use this as the layer between the database itself and the UI. This class shouldn't deal with UI issues, only data issues. For example:

Public Class MyDataLayer
    Public Shared Function LoginUser(ByVal username As String, ByVal password As String) As Boolean
        'Use "username" and "password" variables
        'as your criteria for the SQL call here
        'Call database
        'Provide return result
    End Function
End Class

Now your UI layer (the aspx page) will call this from the Login button click handler:

If MyDataLayer.LoginUser(txtUserName.Text, txtPassword.Text) Then
    'User is logged in, handle accordingly
    'User is NOT logged in, handle accordingly
End If