Click here to Skip to main content
16,005,473 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Clearing javascript cache in IE7 Pin
Mitch F.2-Apr-08 20:11
Mitch F.2-Apr-08 20:11 
GeneralRe: Clearing javascript cache in IE7 Pin
gspiteri3-Apr-08 11:31
gspiteri3-Apr-08 11:31 
GeneralRe: Clearing javascript cache in IE7 Pin
Meg W7-Apr-08 8:03
Meg W7-Apr-08 8:03 
Questionthumbnail picture for shop catalouge [modified] Pin
Saba022-Apr-08 9:45
Saba022-Apr-08 9:45 
GeneralRe: thumbnail picture for shop catalouge Pin
Mark J. Miller2-Apr-08 10:01
Mark J. Miller2-Apr-08 10:01 
GeneralRe: thumbnail picture for shop catalouge Pin
Saba022-Apr-08 10:35
Saba022-Apr-08 10:35 
GeneralRequestSoapContext not found in proxy Pin
mpavas2-Apr-08 7:14
mpavas2-Apr-08 7:14 
QuestionHow do you Authenticate a User saved on SQL Server 2005?? Please Help. Pin
Etienne2-Apr-08 6:34
Etienne2-Apr-08 6:34 
Hi
Can somebody please help me out. I created a Site that works but the code is directed to an Access Database.
I swopped to SQL Server 2005 and need to alter my code to connect and Select the Username and Password from
SQL Server 2005.
What changes do i need to make?
See Code Below please.

Imports System.Collections.Generic

Partial Class MasterPage
Inherits System.Web.UI.MasterPage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

dlgLogin.Focus()

'Sets connectionstring and checks if user is logged in...................................
DBFunctions.setConnectionString(AccessDataSource1.ConnectionString)

If Not IsPostBack Then

'Page counter code...................................................................
If Application("PageCounter") Is Nothing Then
Application("PageCounter") = 1

Else

Application("PageCounter") += 1

End If

lblCounter.Text = Application("PageCounter")

'Connection........................................................................
If Not Session("Email") Is Nothing Then

LoggedIn()

Else

lblName.Visible = False

End If

End If


End Sub

Public Sub LoggedIn()

lblName.Visible = True
linkEdit.Enabled = True
lbtnLogout.Enabled = True
linkEdit.Visible = True
lbtnLogout.Visible = True

'Rater check for Username...............................................................
Try

Dim checkList As List(Of List(Of String)) = DBFunctions.queryRows("SELECT Username FROM Rater WHERE Email = '" + Session("Email") + "'")
lblName.Text = "Hello, " + checkList(0)(0)

lblName.ForeColor = Drawing.Color.DarkGreen


Catch ex As Exception

End Try

'Company check for Company Name................................................................
Try

Dim checkList2 As List(Of List(Of String)) = DBFunctions.queryRows("SELECT Name FROM Company WHERE Email = '" + Session("Email") + "'")
lblName.Text = "Hello, " + checkList2(0)(0)

lblName.ForeColor = Drawing.Color.Black


Catch ex As Exception

End Try


dlgLogin.Visible = False
linkRater.Visible = False
linkComp.Visible = False
linkPassword.Visible = False


End Sub


'boolean, returns true if login successful, false if not
Private Function authenticate(ByVal uname As String, ByVal password As String) As Boolean

'Rater check for email and password................................................................................
Try

Dim checkList As List(Of List(Of String)) = DBFunctions.queryRows("SELECT COUNT(Email) FROM Rater WHERE Email = '" + uname + "' and Password = '" + password + "'")

If checkList(0)(0) = "1" Then

Return True

End If

Catch ex As Exception

End Try


'Company check for email and password.............................................................................
Try

Dim checkList2 As List(Of List(Of String)) = DBFunctions.queryRows("SELECT COUNT(Email) FROM Company WHERE Email = '" + uname + "' and Password = '" + password + "'")

If checkList2(0)(0) = "1" Then

Return True

End If

Catch ex As Exception

End Try


Return False

End Function


Protected Sub dlgLogin_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles dlgLogin.Authenticate

e.Authenticated = authenticate(dlgLogin.UserName, dlgLogin.Password)

End Sub


Protected Sub lbtnLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnLogout.Click

dlgLogin.LoginButtonText = "Log In"
lblName.Visible = False
lbtnLogout.Enabled = False
lblName.Text = "Hello, "


Session.Clear()
Session.Abandon()
Session.RemoveAll()
dlgLogin.Enabled = True
Response.Redirect("Default.aspx")


End Sub

Protected Sub dlgLogin_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles dlgLogin.LoggedIn

Session("Email") = dlgLogin.UserName
LoggedIn()

End Sub

'For setting Label from other forms
Public Property Header() As String

Get
Return lblName.Text
End Get

Set(ByVal value As String)
lblName.Text = value
End Set

End Property


Protected Sub linkEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles linkEdit.Click

If lblName.ForeColor = Drawing.Color.Black Then

Response.Redirect("CompanyRegister.aspx")
Else

Response.Redirect("RaterRegister.aspx")

End If

End Sub
End Class
GeneralRe: How do you Authenticate a User saved on SQL Server 2005?? Please Help. Pin
Mark J. Miller2-Apr-08 10:34
Mark J. Miller2-Apr-08 10:34 
GeneralFormsAuthentication and Session timeout problem. Pin
ESTAN2-Apr-08 6:28
ESTAN2-Apr-08 6:28 
GeneralRe: FormsAuthentication and Session timeout problem. Pin
Mark J. Miller2-Apr-08 10:50
Mark J. Miller2-Apr-08 10:50 
GeneralRe: FormsAuthentication and Session timeout problem. Pin
ESTAN3-Apr-08 22:49
ESTAN3-Apr-08 22:49 
GeneralRe: FormsAuthentication and Session timeout problem. Pin
Mark J. Miller4-Apr-08 4:34
Mark J. Miller4-Apr-08 4:34 
GeneralRe: FormsAuthentication and Session timeout problem. Pin
ESTAN8-Apr-08 2:20
ESTAN8-Apr-08 2:20 
Generalto insert a new record from gridview control Pin
sudhadotnet2-Apr-08 4:37
sudhadotnet2-Apr-08 4:37 
GeneralRe: to insert a new record from gridview control Pin
led mike2-Apr-08 6:50
led mike2-Apr-08 6:50 
Generaliframe src from code Pin
saud_a_k2-Apr-08 3:46
saud_a_k2-Apr-08 3:46 
GeneralRe: iframe src from code Pin
eyeseetee2-Apr-08 4:44
eyeseetee2-Apr-08 4:44 
GeneralRe: iframe src from code Pin
Krishnraj2-Apr-08 19:41
Krishnraj2-Apr-08 19:41 
QuestionHow to display data in content place holder dynamically Pin
psspl2-Apr-08 2:51
psspl2-Apr-08 2:51 
AnswerRe: How to display data in content place holder dynamically Pin
Matthew Ellis2-Apr-08 3:38
Matthew Ellis2-Apr-08 3:38 
AnswerRe: How to display data in content place holder dynamically Pin
eyeseetee2-Apr-08 3:46
eyeseetee2-Apr-08 3:46 
GeneralA potentially dangerous Request.Form value was detected from the client [modified] Pin
Bluebamboo2-Apr-08 1:57
Bluebamboo2-Apr-08 1:57 
GeneralRe: A potentially dangerous Request.Form value was detected from the client Pin
N a v a n e e t h2-Apr-08 3:20
N a v a n e e t h2-Apr-08 3:20 
GeneralRe: A potentially dangerous Request.Form value was detected from the client Pin
Bluebamboo2-Apr-08 4:29
Bluebamboo2-Apr-08 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.