新手请教坛中高手关于用VB.NET和ACCESS数据库制作的登录程序
小弟是个新手,最近在学习,想自己实验制作一个登录程序,但ACCESS数据库和连接写好代码后,就是登录不成功,想请教一下是什么原因,以下是我的代码:Public Class user
Inherits System.Windows.Forms.Form
Public MyCnn As ADODB.Connection
Public MyRs As ADODB.Recordset
public strcnn as string
Private Sub okbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okbtn.Click
Dim i As Integer
Dim Username, Userpwd As String
Dim flag As Boolean
flag = False
Username = Me.userbox.Text
Userpwd = Me.pwdbox.Text
MyCnn = New ADODB.Connection
MyRs = New ADODB.Recordset
strcnn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=d:\conmuser\user.mdb"
MyCnn.Open(strcnn)
MyRs.Open("select * from use", MyCnn, ADODB.LockTypeEnum.adLockUnspecified, ADODB.LockTypeEnum.adLockUnspecified)
MyRs.MoveFirst()
For i = 0 To MyRs.RecordCount - 1
If Username = MyRs.Fields(1).Value Then
If Userpwd = MyRs.Fields(2).Value Then
MessageBox.Show("登录成功")
flag = True
Exit For
End If
End If
MyRs.MoveNext()
Next
If Not flag Then
MessageBox.Show("登录失败")
Else
Dim f As mainfrom
f = New mainfrom
f.Show()
Me.Hide()
End If
End Sub
ACCESS数据库里字段只有两个,一个为ACCOUNT和PASSWORD。请教为什么登录程序提示登录失败?