| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3308 人关注过本帖
标题:根据登录的用户名密码搜索出ACCESS数据库中这一列的信息并分别显示到4个Lab ...
取消只看楼主 加入收藏
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:9 
根据登录的用户名密码搜索出ACCESS数据库中这一列的信息并分别显示到4个Label的Caption中。
图片附件: 游客没有浏览图片的权限,请 登录注册
程序代码:
Private Sub Command1_Click()
'将数据库里的信息显示到LABEL中,筛选条件是根据登录时的用户密码,获取它相应的这一列信息

Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
conn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Aging.mdb " 'a.mdb是ACCESS数据库保存在程序目录下
rs1.Open "Select * From 注册 Where 用户='" & Form1.Text1.Text & "' and 密码='" & Form1.Text2.Text & "'", cn, 2, 3

Form3.Label1.Caption = rs1!用户
Form3.Label2.Caption = rs1!权限
Form3.Label4.Caption = rs1!所属
Form3.Label3.Caption = rs1!SHIFT别



rs1.Close
conn1.Close
Set rs1 = Nothing
Set conn1 = Nothing

搜索更多相关主题的帖子: 密码 登录 Caption 数据库 信息 
2020-04-23 11:15
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
想要实现这样的功能,请教各位大神指教,


补充下:
当前界面是FORM3,
登录界面是FORM1,

[此贴子已经被作者于2020-4-23 11:21编辑过]

2020-04-23 11:16
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 3楼 ZHRXJR
有问题的那条该怎么修改啊?
图片附件: 游客没有浏览图片的权限,请 登录注册


[此贴子已经被作者于2020-4-23 11:53编辑过]

2020-04-23 11:48
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 5楼 ZHRXJR
刚刚试了,达不到效果,还是空白,而且提示语法错误,
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


[此贴子已经被作者于2020-4-23 13:24编辑过]

2020-04-23 12:47
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 7楼 ZHRXJR
程序代码:

Private Sub Form_Load()
Form3.Image4.Picture = Form2.Image7.Picture

Form3.Image1.Picture = Form2.Image8.Picture

Form3.Image2.Picture = Form2.Image10.Picture

Form3.Image3.Picture = Form2.Image12.Picture

Form3.Image5.Picture = Form2.Image14.Picture

Form3.Image6.Picture = Form2.Image16.Picture

Form3.Image7.Picture = Form2.Image18.Picture

Form3.Image8.Picture = Form2.Image20.Picture

Form3.Image9.Picture = Form2.Image20.Picture

Form3.Image10.Picture = Form2.Image22.Picture

Form3.Image11.Picture = Form2.Image24.Picture

Form3.Image12.Picture = Form2.Image26.Picture

Form3.Image13.Picture = Form2.Image28.Picture


Form3.Label5.Caption = Date

Form3.Label6.Caption = Time


rs1.Open "Select * From 注册 Where 用户='" & YHMC & "' and 密码='" & YHMM & "'", cn, 2, 3



End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image1.Picture = Form2.Image8.Picture

Form3.Image2.Picture = Form2.Image10.Picture

Form3.Image3.Picture = Form2.Image12.Picture

Form3.Image5.Picture = Form2.Image14.Picture

Form3.Image6.Picture = Form2.Image16.Picture

Form3.Image7.Picture = Form2.Image18.Picture

Form3.Image8.Picture = Form2.Image20.Picture

Form3.Image9.Picture = Form2.Image20.Picture

Form3.Image10.Picture = Form2.Image22.Picture

Form3.Image11.Picture = Form2.Image24.Picture

Form3.Image12.Picture = Form2.Image26.Picture

Form3.Image13.Picture = Form2.Image28.Picture


End Sub

Private Sub Image1_Click()
Form6.Show
Form3.Hide

End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image1.Picture = Form2.Image9.Picture
Form3.Image2.Picture = Form2.Image10.Picture



End Sub

Private Sub Image10_Click()
Form3.Hide

Form4.Show

End Sub

Private Sub Image10_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image10.Picture = Form2.Image23.Picture

End Sub

Private Sub Image11_Click()
Form9.Show
Form3.Hide

End Sub

Private Sub Image11_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image11.Picture = Form2.Image25.Picture

End Sub

Private Sub Image12_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image12.Picture = Form2.Image27.Picture

End Sub

Private Sub Image13_Click()


Form3.Hide
Form1.Show
Form1.Text1.Text = ""
Form1.Text2.Text = ""
Form1.Text1.SetFocus



End Sub

Private Sub Image13_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image13.Picture = Form2.Image29.Picture

End Sub

Private Sub Image2_Click()
Form7.Show
Form3.Hide

End Sub

Private Sub Image2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image2.Picture = Form2.Image11.Picture
'Form3.Image1.Picture = Form2.Image8.Picture
End Sub

Private Sub Image3_Click()
Form5.Show
Form3.Hide


End Sub

Private Sub Image3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image3.Picture = Form2.Image13.Picture
End Sub

Private Sub Image4_Click()
End

End Sub

Private Sub Image5_Click()
Form6.Show
Form3.Hide
End Sub

Private Sub Image5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image5.Picture = Form2.Image15.Picture

End Sub

Private Sub Image6_Click()
Form6.Show
Form3.Hide
End Sub

Private Sub Image6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image6.Picture = Form2.Image17.Picture

End Sub

Private Sub Image7_Click()
Form8.Show
Form3.Hide

End Sub

Private Sub Image7_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image7.Picture = Form2.Image19.Picture

End Sub

Private Sub Image8_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image8.Picture = Form2.Image21.Picture

End Sub

Private Sub Image9_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form3.Image9.Picture = Form2.Image21.Picture

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

End Sub

Private Sub Timer1_Timer()
Form3.Label5.Caption = Date

Form3.Label6.Caption = Time
End Sub
2020-04-23 13:42
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 9楼 ZHRXJR
我觉得是不是我的思路就错了,
是不是可以这样,在RORM3里面建立一个隐藏的TEXT,在FORM1登录时,将FORM1.TEXT内容传给FORM3.TEXT,
在LOADING FOrmM时,再根据这个text内容进行查询并显示到LABEL里面,

这方案怎么样?
2020-04-23 16:49
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏(1)
得分:0 
回复 9楼 ZHRXJR
程序代码:
Dim cn12 As New ADODB.Connection
Dim rs12 As New ADODB.Recordset
cn12.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Aging.mdb "

rs12.Open "Select * From 注册 Where 用户='" & Text1.Text & "', cn12, 2, 3"

   

 Form3.Label1.Caption = rs!用户

 Form3.Label2.Caption = rs!权限

 Form3.Label4.Caption = rs!班次

 Form3.Label3.Caption = rs!所属
    
            rs12.Close
            Set rs12 = Nothing
            cn12.Close
            Set cn12 = Nothing

 
            Exit Sub
     
rs12.Close
Set rs12 = Nothing
cn12.Close
Set cn12 = Nothing



当前通过一个按钮,想实现把查询到的数据显示到LABEL中,代码有问题,请帮忙看看,
2020-04-23 17:50
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 12楼 ZHRXJR
呵呵,自己买了本书,看的学,所以有很多不理解的地方,希望继续得到你的指导,
2020-04-24 14:54
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 13楼 ZHRXJR
可以把你理解的那种方案,代码写给我看看吗?谢谢了,

就是我们最原始要求的那种效果,FORM1里面的 用户 密码登录时,FORM3 LOADNG时根据它们进行查询4个内容到LABLE1,LABLE2,LABLE3,LABLE4中.
2020-04-24 15:56
wangyiaihu
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2020-4-22
收藏
得分:0 
回复 16楼 ZHRXJR
把你邮箱发给我,我发给你,
2020-04-24 18:44
快速回复:根据登录的用户名密码搜索出ACCESS数据库中这一列的信息并分别显示到4 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029307 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved