我做了一个登录页面,内容如下:一个在外面建的数据库(access 2000),用Adodc1连接数据库,数据库连接没有错,内容都设置了,在form1(登录页面)中,text1.field=username,text2.field=password.我的代码如下:
Private Sub Command1_Click()‘command1为提交按钮
If Text1.Text = Text1.DataField And Text2.Text = Text2.DataField Then
Form1.Hide
Form2.Show
Else
MsgBox "错误的用户名或密码,您不能登录,请重试!", vbOKOnly, "登录"
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
Text1.SelStart = 0
Text2.SetFocus
Text2.SelLength = Len(Text2.Text)
Text2.SelStart = 0
End If
End SubPrivate Sub Command2_Click()‘common2为重试按钮
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
Text1.SelStart = 0
Text2.SetFocus
Text2.SelLength = Len(Text2.Text)
Text2.SelStart = 0End Sub
现在问题是:明明我的数据库中有几个记录,但是,无论输入什么只会显示:
错误的用户名或密码,您不能登录,请重试!
实在不知道为什么?请大家给指点一下。那个Adodc1怎么用?谢谢!!
Private Sub Command1_Click()‘command1为提交按钮
If Text1.Text = Text1.DataField And Text2.Text = Text2.DataField Then
Form1.Hide
Form2.Show
Else
MsgBox "错误的用户名或密码,您不能登录,请重试!", vbOKOnly, "登录"
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
Text1.SelStart = 0
Text2.SetFocus
Text2.SelLength = Len(Text2.Text)
Text2.SelStart = 0
End If
End SubPrivate Sub Command2_Click()‘common2为重试按钮
Text1.SetFocus
Text1.SelLength = Len(Text1.Text)
Text1.SelStart = 0
Text2.SetFocus
Text2.SelLength = Len(Text2.Text)
Text2.SelStart = 0End Sub
现在问题是:明明我的数据库中有几个记录,但是,无论输入什么只会显示:
错误的用户名或密码,您不能登录,请重试!
实在不知道为什么?请大家给指点一下。那个Adodc1怎么用?谢谢!!
好象错在这句上。
字段名没有,或是记录没有移动
Public myword As ADODB.Recordset
Public zt As String
Sub main()
Set cnn = New ADODB.Connection
cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\库名.mdb"
cnn.ConnectionTimeout = 30
cnn.CursorLocation = adUseClient
cnn.Open
Form1.Show
End Sub
Private Sub Form_Load()
Set myword = New ADODB.Recordset
myword.Open "select * from 表名 where name='"& trim(text1.text) &"' and password='"& trim(text2.text) &"'", cnn, adOpenDynamic, adLockPessimistic
if myword.recordcount>=1 then
Form1.Hide
Form2.Show
else
...........
这种定义和Adodc1是一样的
我的不用把Adodc1放到窗体上
直接用就行。别望了工程中的引用mocrosoft active data object2.0 library