I have login interface for Access database
it giving errors pls help
Nuwan
it giving errors pls help
VB.NET:
Imports System.Data
Imports System.Data.OleDb
Public Class frmLogin
Inherits System.Windows.Forms.Form
'---------------------------------------------------------
Private strConnectionString As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\Nuwan\Login\Loginbase.mdb;"
Private objConnection As OleDbConnection
Private objCommand As OleDbCommand
Private objDataAdapter As OleDbDataAdapter
Private objDataSet As DataSet
Private objDataReader As OleDbDataReader
'---------------------------------------------------------
Dim Ctr As Integer
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
'Dim LoginName As String, Password As String
Dim flag As Boolean
flag = False
'LoginName = txtUserName.Text
'Password = txtPassword.Text
Ctr = Ctr + 1
'----------------------------------------
objConnection = New OleDbConnection(strConnectionString)
objConnection.Open()
'Initialize the Command object
objCommand = New OleDbCommand
'Set the objCommand object properties
objCommand.CommandText = "LoginTable"
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Connection = objConnection
'Add the required parameter for the query
objCommand.Parameters.Add("LoginNameD", OleDbType.Guid, 16).Value = _
New Guid(txtUserName.Text)
objDataReader = objCommand.ExecuteReader()
'If we have data then display the project description
If objDataReader.HasRows Then
objDataReader.Read()
'----------------------------------------
If txtUserName.Text = objDataReader.Item("PasswordD") Then
lblMessage.Text = "Welcome to Alarm Monitoring System Data Entry"
Ctr = 0
Dim frm As New Form2
frm.Show()
Else
If Ctr < 3 Then
lblMessage.Text = "Incorrect User Name or Password - Please Try again"
txtUserName.Focus()
Else
MsgBox("Unauthorized Access. Aborting...")
Close()
End If
End If
End If
'----------------------------------------
'Close the DataReader and Connection
objDataReader.Close()
objConnection.Close()
'Clean up
objDataReader = Nothing
objCommand.Dispose()
objCommand = Nothing
objConnection.Dispose()
objConnection = Nothing
'----------------------------------------
End Sub
Nuwan