Hello i m new to ASP.net, i have created a form and have these controls on it
1. Login Name Textbox
2. Password Textbox
3. A button (Form Submit Button not the HTML Submit button)
4. A label named lblNote to show a simple msg that login is successful or not.
I have a Database named LoginSite.mdb which is a part of my project. This database has only loginName and Password in it.
Now i wrote this code in my button click event.
The problem is that i m not able to see the lblNote label with any kind of information about the login being successful or not. lblNote is not being displayed.Code:Imports System.Data.OleDb Partial Class MainForm Inherits System.Web.UI.Page Dim dbConn As OleDbConnection Dim dbcmd As New OleDbCommand Dim rs As OleDbDataReader Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dbConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("LoginSite.mdb")) dbconn.Open() dbcmd.Connection = dbConn End Sub Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click Try dbcmd.CommandText = "Select * from LoginTBL" rs = dbcmd.ExecuteReader() While (IsDBNull(rs)) If (rs("loginName").Equals(txtLoginName.Text) = True And rs("loginPassword").Equals(txtPassword.Text) = True) Then lblNote.Visible = True lblNote.Text = "You have been Successfully Logged in" Else lblNote.Visible = True lblNote.Text = "Error Logging In !!!" End If End While Catch ex As Exception lblNote.Text = "Error Logging In !!!" End Try End Sub End Class
Please Help !!!


Reply With Quote
