im having problem with my login page.
as it return NullReferenceException
it is something with my database connection.
i think it is just fine.
<connectionStrings>
<add name="CnnctStrg" connectionString="Data Source=PC-4;Initial Catalog=sqldb;User ID=123;Password=123;" providerName="System.Data.SqlClient"/>
</connectionStrings>
i guess its the problem with my login button.
this is my code for the login button
Protected Sub btnlogin_Click(sender As Object, e As ImageClickEventArgs) Handles btnlogin.Click
Dim bytHashedData As Byte()
Dim encoder As New UTF8Encoding()
Dim md5Hasher As New MD5CryptoServiceProvider
Try
OAuthen = New Authenticate
If tbusername.Text <> "" And tbpassword.Text <> "" Then
OAuthen.Username = Me.tbusername.Text.Trim()
bytHashedData = md5Hasher.ComputeHash(encoder.GetBytes(tbpassword.Text.Trim & tbusername.Text.Trim))
OAuthen.Password = bytHashedData
End If
'OAuthen.Username = Me.tbusername.Text.Trim()
'OAuthen.Password = Me.tbpassword.Text.Trim()
If Session("activatecounter") Is Nothing Then
Session("activatecounter") = 3
End If
OAuthen.AttemptCounter = CInt(Session("activatecounter")) - 1
If Session("counter") Is Nothing Then
Session("counter") = 3
End If
OAuthen.AttemptCounter = CInt(Session("counter")) - 1
If Authenticate.Authenticate_Admin Then 'from local function,error might thrown from SQL native client
If OAuthen.SPRetValue = 0 Then 'from SP, other than ZERO is always failure to login
Session.Remove("loginMsg")
Session.Remove("counter")
Session("validusr") = Session.SessionID
Session("accid") = OAuthen.AccountID
Session("User_Name") = OAuthen.StaffName
Session("lastlogon") = OAuthen.LastLogon '), "dd MM yy hh:mm tt")
Response.Redirect("~/Main/MainPage.aspx?id=" + Session("accid").ToString, True)
Else
Session("loginMsg") = OAuthen.LoginMsg
Dim retval As Integer
retval = OAuthen.SPRetValue
If OAuthen.SPRetValue = -2 Then 'invalid username or password
Dim counter As Integer = Session("counter")
counter = counter - 1
Session("counter") = counter
End If
Me.lblmsg.Text = Session("loginMsg").ToString
'back to login page
Response.Redirect("~/LoginPanel.aspx?login_attempt=YES")
End If
Else
'Response.Write(OAuthen.ExceptionMsg)
Session("loginMsg") = OAuthen.ExceptionMsg
Me.lblmsg.Text = Session("loginMsg").ToString
Response.Redirect("~/LoginPanel.aspx")
End If
Catch ex As Exception
End Try
End Sub
can u please help me? its been days ive stuck in this.