| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 954 人关注过本帖
标题:[求助]用adodc控件做的登陆窗全验证失败了
只看楼主 加入收藏
lan9203
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2006-10-22
收藏
 问题点数:0 回复次数:1 
[求助]用adodc控件做的登陆窗全验证失败了

Module1模块

Option Explicit
Public AdodcPath As String '这是adodc控键共用数据库
Public userPassword As String
Public username As String
Public Sub InitializeDataPath() '对数据库的路径进行初始化,使用相对的路径,只要数据库与程序在同一目录下即可保证数据的正常访问了

If Right(App.Path, 1) <> "\" Then '是为在打包的时候可能出现无斜杆的防错吗?
AdodcPath = App.Path & "\library.mdb"
Else
AdodcPath = App.Path & "library.mdb"
End If

End Sub


登陆窗体:

Private Sub cmdOK_Click()

If intcount >= 3 Then
MsgBox "非法用户!", vbOKOnly + vbExclamation, ""
Exit Sub
End
End If

If txtuser.Text = "" Or txtPassword.Text = "" Then
MsgBox "请输入用户名与密码!", vbOKOnly + vbInformation, ""
Exit Sub
End If

With rsUserTable
rsUserTable.Find " 用户帐号 = '" & txtuser.Text & "'"

If .EOF Then
intcount = intcount + 1
MsgBox "用户名不存在!", vbOKOnly + vbInformation, ""
txtuser.Text = ""
txtuser.SetFocus
Exit Sub
End If

.Find "用户密码 ='" & txtPassword.Text & "'"
If .EOF Then
intcount = intcount + 1

MsgBox "您输入密码不正确!", vbOKOnly + vbInformation, ""
txtPassword.Text = ""
txtPassword.SetFocus
Exit Sub

End If

End With
username = txtuser.Text
userPassword = txtPassword.Text

Unload Me

Load MDIForm1
MDIForm1.Show

End Sub


Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub Form_Load()
InitializeDataPath
Adodc1.ConnectionString = AdodcPath

Adodc1.RecordSource = "select * from usertable"
Adodc1.Refresh
Set rsUserTable = Adodc1.Recordset
End Sub




出错提示:
错误定位在:Adodc1.Refresh
[Microsoft][ODBC驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序

如果将Adodc1.Refresh注解掉,出现的错误是这样的:
实时错误 '91':
对象变量或 with 模块变量未设置
错误定位在:rsUserTable.Find " 用户帐号 = '" & txtuser.Text & "'"

[此贴子已经被作者于2006-11-5 1:55:47编辑过]

搜索更多相关主题的帖子: adodc 控件 验证 登陆 
2006-11-05 01:47
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
用个Sql语句来查询吧..
"Select * From 表 Where 用户名='" & text1.text & "' And 密码='" & textbox1.text & "'"

我的msn: myfend@
2006-11-05 09:20
快速回复:[求助]用adodc控件做的登陆窗全验证失败了
数据加载中...
 
   



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

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