本文介绍了当我在其他系统上运行Vb.Net项目时,我在Con.Open()中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是用于验证来自访问数据库的用户名和密码的登录页面代码
This is login page code for verifying username and password from access database
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("ENTER USERNAME OR PASSWORD", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
else
If ask() = True Then
Employee.Show()
Else
MsgBox("INCORRECT USERNAME OR PASSWORD", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
End If
End If
End Sub
Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "provider= microsoft.jet.oledb.4.0;data source = ..\debug\EmployeeFullDataBase.mdb"
End Sub
Public Function ask()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
con.Open()
Dim da As New OleDbDataAdapter("Select * from EmployeeFullData", con)
da.Fill(dt)
For Each DataRow In dt.Rows
If TextBox1.Text = DataRow.item(11) And TextBox2.Text = DataRow(12) Then
con.Close()
Return True
End If
Next
con.Close()
Return False
End Function
推荐答案
这篇关于当我在其他系统上运行Vb.Net项目时,我在Con.Open()中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!