作者在 2012-06-07 22:39:22 发布以下内容
Imports System.Data
Imports System.Data.OleDb
Imports System.String
Public Class Login
Dim sProvider As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
Dim sDataSource As String = "Data Source= E:\Code\VB\NewManagerSystem\DataBase\NewsManagerSystem.mdb"
Dim sConnString As String = sProvider & sDataSource
Dim WithEvents myCn As New OleDbConnection
Private Property myDataSet As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' login new manager system
' retrieve current username and password
Dim userName As String
Dim password As String
Dim Sql As String
userName = UsrNameText.Text
password = PsdText.Text
Try
myCn.ConnectionString = sConnString
myCn.Open()
'MsgBox("连接正确!!")
' open Password table to access
Sql = "SELECT * FROM passwd"
' create data set
myDataSet = New DataSet()
' get a data set
Dim myCommand As OleDbDataAdapter = New OleDbDataAdapter(Sql, myCn)
'Let Dataset bind Password table
myCommand.Fill(myDataSet, " passwd")
Dim bLogin As Boolean
bLogin = False
'verify curent value validate or not?
If (Not myDataSet Is Nothing) Then
For Each cRow As DataRow In myDataSet.Tables(0).Rows
If (String.Compare(userName, cRow.ToString(), True) = 0) Then
bLogin = True
End If
Next
End If
If (bLogin = True) Then
MsgBox("Login successfully")
Else
MsgBox("Login unsuccessfully")
End If
'close OleDbConnection
myCn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
' verify current username and password whether they fulfill condition.
' if it fulfills jump to main interface or prompt error information
' if the input times is more then 3. pop up error message and close current system.
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' quit new manager system
End Sub
End Class
Imports System.Data.OleDb
Imports System.String
Public Class Login
Dim sProvider As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
Dim sDataSource As String = "Data Source= E:\Code\VB\NewManagerSystem\DataBase\NewsManagerSystem.mdb"
Dim sConnString As String = sProvider & sDataSource
Dim WithEvents myCn As New OleDbConnection
Private Property myDataSet As DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' login new manager system
' retrieve current username and password
Dim userName As String
Dim password As String
Dim Sql As String
userName = UsrNameText.Text
password = PsdText.Text
Try
myCn.ConnectionString = sConnString
myCn.Open()
'MsgBox("连接正确!!")
' open Password table to access
Sql = "SELECT * FROM passwd"
' create data set
myDataSet = New DataSet()
' get a data set
Dim myCommand As OleDbDataAdapter = New OleDbDataAdapter(Sql, myCn)
'Let Dataset bind Password table
myCommand.Fill(myDataSet, " passwd")
Dim bLogin As Boolean
bLogin = False
'verify curent value validate or not?
If (Not myDataSet Is Nothing) Then
For Each cRow As DataRow In myDataSet.Tables(0).Rows
If (String.Compare(userName, cRow.ToString(), True) = 0) Then
bLogin = True
End If
Next
End If
If (bLogin = True) Then
MsgBox("Login successfully")
Else
MsgBox("Login unsuccessfully")
End If
'close OleDbConnection
myCn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
' verify current username and password whether they fulfill condition.
' if it fulfills jump to main interface or prompt error information
' if the input times is more then 3. pop up error message and close current system.
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' quit new manager system
End Sub
End Class