VB6新建工程,添加登录对话框,修改其代码,用ADO数据控件连接ACCESS数据库,将txtPassword文本控件的DataSource属性写为ADODC1,属性DataField写为数据表的密码字段名,并将Adodc1的属性ConnectionString中的数据库路径改写为你的数据库路径,代码如下:
Private Sub Form_Load()
Text3 = ""
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtPassword = Text3
Adodc1.Recordset(1) = txtPassword
Adodc1.Recordset.Update
Adodc1.Refresh
End If
End Sub
Private Sub txtUserName_Change()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\biyesheji\mygzs\program\vb\db1.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from userpass where UserName like'" & txtUserName & "%'"
Adodc1.Refresh
txtPassword = Adodc1.Recordset(1)
End Sub