VB 记录登录名

来源:百度知道 编辑:UC知道 时间:2024/06/11 15:32:25
我用VB从access数据库中调用“用户名”和“密码”来登录到某个窗体,我想要在这个窗体打开后立刻显示所登录的“用户名”存在数据库中的详细信息,该怎么办?

可以在公共模块中定义几个全局变量,用户登录时将相关值赋给这些全局变量,以后需要显示的时候直接读取这些变量的值即可

在显示的窗体中加个ADODC!
adodc1.recordsourse="select * from 表 where 用户名=“```”‘如果要调用控件的属性要像‘"&label7.cation&"’"这样
adodc1.refresh
lable1.caption=adodc1.recordset.fields(字段名)
``
```

可以在登录后把用户名写入 .ini 文件中,下次登录直接访问这个文件。

新增Module并宣告struser
Public struser As String
---------------------------------
Private Sub cmdlogin_Click()
If txtuser = "" Then
MsgBox "Please fill in User三 Name.", vbInformation + vbOKOnly, "Information"
txtuser.SetFocus
Exit Sub
End If

If txtpassword = "" Then
MsgBox "Please fill in Password.", vbInformation + vbOKOnly, "Information"
txtpassword.SetFocus
Exit Sub
End If

Dim SQL As String
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "