各位大虾帮帮忙!我想用vb做个用户登录面

63712885 2004-10-11 10:33:44
我是用vb和access做的,我因为刚刚起步,希望各位大虾帮帮忙,小弟不会忘记的,,,,
希望能给点代码,并能注译一下好吗?谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
...全文
104 点赞 收藏 12
写回复
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
63712885 2004-10-11
Set mcnn = New ADODB.Connection这句为什么运行会出错啊提示connection没定义
回复
starsoulxp 2004-10-11
楼上的这句是什么意思?
Private Sub CheckLogin()


那是我自己定义的过程,你可以根据你程序的需要自己改
回复
flyingZFX 2004-10-11
呵呵,这咋帮你呀,
回复
starsoulxp 2004-10-11
写错了,是ADODC 控件,Microsoft ADO Data Control
回复
63712885 2004-10-11
楼上的这句是什么意思?
Private Sub CheckLogin()
回复
starsoulxp 2004-10-11
你还要在菜单中的"工程"--"引用"中,选中"Microsoft ActiveX Data Objects 2.0 Library"
或者添加ADODB控件
回复
starsoulxp 2004-10-11
Private Sub CheckLogin()
Dim sql As String
Dim mcnn, rs
Dim username As String
Dim password As String
username = Trim(txtUsername.Text)
password = txtPassword.Text
Set mcnn = New ADODB.Connection
mcnn.Open "provider=Microsoft.jet.oledb.4.0;persist security info=false;data source=" & App.Path & "\inc\mm.mdb"
Set rs = New ADODB.Recordset
Select Case LoginType
Case "teacher"
sql = "select * from Teacher where Username='" & username & "'"
Case "student"
sql = "select * from Student where Username='" & username & "'"
End Select
rs.Open sql, mcnn, , , adCmdText
'On Error GoTo eLoop
If rs.EOF Then
SetOnTop frmLogin, False
MsgBox "对不起,该用户名不存在!", 48, "心理测量系统"
SetOnTop frmLogin, True
txtUsername.SetFocus
txtUsername.SelStart = 0
txtUsername.SelLength = Len(txtUsername.Text)
Else
If rs("UserPassword") = password Then
LoginSucceeded = True
User = username '传递登录的用户模块级变量User
Unload Me
frmMain.Show
rs.Close
Set rs = Nothing
mcnn.Close
Set mcnn = Nothing

Else
SetOnTop frmLogin, False
MsgBox "对不起,密码错误!", 48, "心理测量系统"
SetOnTop frmLogin, True
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
End If

End Sub
回复
63712885 2004-10-11
出错,提示,用户定义的类型没有定义Dim db As New ADODB.Connection
回复
lujianyu1189 2004-10-11
我给你示例吧,我的email:lujianyu-jx@126.com
回复
tztz520 2004-10-11
你还要在菜单中的"工程"--"引用"中,选中"Microsoft ActiveX Data Objects 2.0 Library"
回复
tztz520 2004-10-11
'Text1是输入用户名.Text2是输入密码的
Private Sub Command22_Click()
Dim i As Integer
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
db.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & "data source=" & App.Path & "\dev.mdb"
db.Open
rs.CursorLocation = adUseClient
If Trim(Text1.Text) = "" Or Trim(Text1.Text) = "" Then
MsgBox "用户名或密码不能为空"
Else
rs.Open "select * from Usertable where username='" & Trim(Text1.Text) & "' and password='" & Trim(Text2.Text) & "'", db
If rs.RecordCount > 0 Then
MsgBox "成功登录!"
Else
MsgBox "密码或用户名不正确"
End If
End If
End Sub
回复
riverlee 2004-10-11
vb新建FROM时使用向导,里面有登陆窗体,自己加点代码就可以了。
回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告