Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft ASP .NET
New to Classes, please help.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="David Lozzi, post: 3861866"] Howdy, I'm new to classes. Below is my class User. (is this a reserved namespace or class?) It works great, kind of. If I specify the username and password, the correct firstname and lastname are returned. For example, username dlozzi, password fun. It returns David Lozzi as full name. If I login as someone else on another computer, say username dsmith and password fun2, the second computer displays the correct fullname. HOWEVER if I refresh the page on the first computer where I logged in under dlozzi, the information is now dsmith's info. I believe I am just missing one small piece, but I just cannot find it. Should I be using Session states along with classes? Thanks! David Lozzi Imports System.Configuration Imports System.Data.SqlClient Public Class User Private Shared sqlConn As String = ConfigurationSettings.AppSettings("ConnectionString") Private Shared _firstname As String Private Shared _lastname As String Private Shared _username As String Private Shared _password As String Public Shared Function Login() As Boolean _username = Replace(_username, "'", "''") _password = Replace(_password, "'", "''") Dim sqlQry As String = "cp_GetUser '" & _username & "'" Dim myConnection As New SqlConnection(sqlConn) myConnection.Open() Dim myCommand As New SqlCommand(sqlQry, myConnection) Dim rec As SqlDataReader rec = myCommand.ExecuteReader() If Not rec.Read Then Login = False Else If _password = rec("strPassword") Then _firstname = rec("strFirstName") _lastname = rec("strLastName") _password = "none" Login = True End If End If End Function Public Shared Property FirstName() As String Get Return _firstname End Get Set(ByVal Value As String) _firstname = Value End Set End Property Public Shared Property LastName() As String Get Return _lastname End Get Set(ByVal Value As String) _lastname = Value End Set End Property Public Shared ReadOnly Property FullName() As String Get Return _firstname & " " & _lastname End Get End Property Public Shared ReadOnly Property FullNameRev() As String Get Return _lastname & ", " & _firstname End Get End Property Public Shared Property UserName() As String Get Return _username End Get Set(ByVal Value As String) _username = Value End Set End Property Public Shared Property Password() As String Get Return _password End Get Set(ByVal Value As String) _password = Value End Set End Property End Class [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft DotNet
Microsoft ASP .NET
New to Classes, please help.
Top