GP Bundel Vandaele Johno

Page 38

Object Inlog.aspx btnLogin

Gebeurtenis Load Click

Doel LitLogin waarde geven Login

Imports System.Data.SqlClient Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Session("Login") = False Then Session("Login") = False litLogin.Text = "<a href=""Login.aspx"">Login</a>" Else If Session("Login") = True Then Session("Login") = True litLogin.Text = "<a href=""Account.aspx"">Account</a>" End If End If End Sub Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click Dim sqlcmd As New SqlCommand Dim sqlcon As New SqlConnection(ConfigurationManager.ConnectionStrings("cnnGpWebsite").ConnectionS tring) Dim strsql As String Dim Username As New HttpCookie("Username") sqlcon.Open() strsql = "SELECT COUNT(UserID) FROM tblUser WHERE username='" & txtUser.Text & "' AND Password='" & txtPass.Text & "'" With sqlcmd .Connection = sqlcon .CommandText = strsql End With 'afhandelen 0 of 1 If sqlcmd.ExecuteScalar > 0 Then Session("Login") = True Username.Value = txtUser.Text Username.Expires = Now.AddHours(3) Response.Cookies.Add(Username) sqlcon.Close() strsql = "" strsql = "SELECT UserID FROM tblUser WHERE username='" & txtUser.Text & "'" With sqlcmd .Connection = sqlcon .CommandText = strsql End With sqlcon.Open() Dim datareader As SqlDataReader = sqlcmd.ExecuteReader() Do While datareader.Read Session("UserID") = datareader.Item("UserID").ToString Loop

Geintegreerde proef

38


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.