Public Function IsLoggedIn(ByVal PassUserName As String, ByVal PassPassword As String) As Boolean Public IsAdminUser As Boolean = False
It gives me error how should i declare it.




Posted 01 September 2010 - 08:44 PM
Public Function IsLoggedIn(ByVal PassUserName As String, ByVal PassPassword As String) As Boolean Public IsAdminUser As Boolean = False
Posted 01 September 2010 - 09:58 PM
Module GlobalStuff
'this is our variable that tells us whether the logged in user is
' an admin or not. It is available anywhere in the application.
Public IsAdminUser As Boolean = False
Public Function IsLoggedIn(ByVal PassUserName As String, ByVal PassPassword As String) As Boolean
Dim ReturnBool As Boolean = True
Dim cnString As String = "Data Source=ITS;Initial Catalog=Payment;Integrated Security=True"
Dim conn As SqlConnection = New SqlConnection(cnString)
Dim sql = "SELECT Username,Pass,IsAdmin FROM Login WHERE Username = '" & PassUserName & "' AND Pass = '" & PassPassword & "'"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Try
conn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
'ReturnBool = dr.Read()
' since the select statement is going to return a value that
' we want to read we will go ahead and read it in
If dr.Read() Then
GlobalStuff.IsAdminUser = Convert.ToBoolean(dr("IsAdmin").ToString())
Else
GlobalStuff.IsAdminUser = False
ReturnBool = False
End If
Catch Exp As SqlException
ReturnBool = False
'Put other code to handle, log, etc... errors here
Catch Exp As Exception
ReturnBool = False
'Put other code to handle, log, etc... errors here
Finally
If conn IsNot Nothing AndAlso conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Try
Return ReturnBool
End Function
End Module
Posted 01 September 2010 - 11:30 PM
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button2.Enabled = False
Button4.Enabled = False
GlobalStuff.IsAdminUser()
End Sub
This post has been edited by naveed_786: 01 September 2010 - 11:32 PM
Posted 01 September 2010 - 11:41 PM
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button2.Enabled = GlobalStuff.IsAdminUser
Button4.Enabled = True
Button22.Enabled = Not GlobalStuff.IsAdminUser
End Sub
This post has been edited by demausdauth: 01 September 2010 - 11:42 PM
Posted 02 September 2010 - 05:03 AM
Posted 02 September 2010 - 06:57 AM
Posted 05 September 2010 - 12:32 AM
Posted 07 September 2010 - 06:28 AM
demausdauth, on 27 August 2010 - 01:28 PM, said:
Posted 07 September 2010 - 03:01 PM
Button2.Enabled = GlobalStuff.IsAdminUser
This post has been edited by naveed_786: 07 September 2010 - 03:02 PM
Posted 08 September 2010 - 05:33 AM
Posted 10 September 2010 - 02:54 AM
Posted 15 September 2010 - 08:06 PM
Posted 16 September 2010 - 05:49 AM
demausdauth, on 07 September 2010 - 06:28 AM, said:
Posted 17 September 2010 - 04:44 AM
Posted 17 September 2010 - 05:12 AM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
