VB与access 制作登陆界面问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:12:18
Public con As ADODB.Connection
Sub Main()
ChDir App.Path
Set con = New ADODB.Connection

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data\data.mdb;" & "jet oledb:database password=mydbpassword;""6845419"""

con.CursorLocation = adUseClient

con.Open
Form3.Show
End Sub

Private Sub Command1_Click()
If (Text1.Text = "") Or (Text2.Text = "") Then
MsgBox "对不起!用户名或密码不能为空……", 64, "登陆错误:"
Exit Sub
End If
Dim coon As String
Dim coom As String
Dim rs As New ADODB.Recordset
coon = Text1.Text
coom = Text2.Text
SQL = "select * from admin where admin='" + coon + "' and password='" + coom + "'"
rs.Open SQL, con
If rs.EOF Then
MsgBox "用户名或密码错误……!", 64, "登陆错误:"
Text1.Text = ""
Text2

你的模块在哪...
以下是我的你参考:
模块..
Public con As New Connection '定义数据连接,公共变量
Public coon, coom As String
Public str As Currency

Sub main()
ChDir App.Path '转换相对路径

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data.mdb;Persist Security Info=False"
'定义数据库连接
con.CursorLocation = adUseClient '以客户端的方式打开

con.Open ' 打开连接
dl.Show
End Sub

登陆窗体...
Dim rec As New Recordset
Dim rs As New Recordset
Private Sub Command1_Click()

If (Text1.Text = "") Or (Text2.Text = "") Then
MsgBox "用户名和密码不能为空!", vbOKOnly, "错误"
Exit Sub
End If
coon = Text1.Text
coom = Text2.Text
sql = "select * from dl where gly='" + coon + "' and mm='" + coom + "'"
Set rs = con.Execute(sql)
If rs.EOF Then
MsgBox "用户名和密码错误!", vbOKOn