登陆界面的代码如下:
Dim Tim As Integer '定义一个整型变量
Dim rs1 As New ADODB.Recordset '定义一个数据集对象
Private Sub Form_Activate()
DataCombo1.SetFocus
End Sub
Private Sub DataCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text2.SetFocus 'Text2获得焦点
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.Visible = True
Command1.SetFocus
End If
End Sub
Private Sub Command1_Click()
rs1.Open "select * from 用户表_xx044_19 where 用户名='" & DataCombo1.BoundText & "'", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
If DataCombo1.Text = "" Then
MsgBox ("请选择用户!"), vbOKOnly
DataCombo1.SetFocus
Exit Sub
End If
'验证用户名及密码
Dim MESSAGE As String
Textime.Text = Tim
If Text2.Text = rs1.Fields("密码") Then
Load frm_main
frm_main.Show
czy = DataCombo1.Text
Unload Me
Else
If Tim = 3 Then
MESSAGE = MsgBox("密码输入错误,请向系统管理员查询!", 0, "")
If MESSAGE = vbOK Then End
End If
If Text2.Text <> rs1.Fields("密码") Then
MsgBox ("密码错误,请重新输入密码!")
Tim = Tim + 1
Text2.SetFocus
End If
End If
Else
Load frm_main
frm_main.Show
Unload Me
End If
rs1.Close
End Sub
Private Sub Command2_Click()
End
End Sub运行的时候老是出现如下的错误:
实时错误'3001':参数类型不正确,或在不可以接受的范围之内,或与其他参数冲突。
vb我也是刚学,怎么也搞不定,请高手指点下
Dim Tim As Integer '定义一个整型变量
Dim rs1 As New ADODB.Recordset '定义一个数据集对象
Private Sub Form_Activate()
DataCombo1.SetFocus
End Sub
Private Sub DataCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text2.SetFocus 'Text2获得焦点
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.Visible = True
Command1.SetFocus
End If
End Sub
Private Sub Command1_Click()
rs1.Open "select * from 用户表_xx044_19 where 用户名='" & DataCombo1.BoundText & "'", Cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
If DataCombo1.Text = "" Then
MsgBox ("请选择用户!"), vbOKOnly
DataCombo1.SetFocus
Exit Sub
End If
'验证用户名及密码
Dim MESSAGE As String
Textime.Text = Tim
If Text2.Text = rs1.Fields("密码") Then
Load frm_main
frm_main.Show
czy = DataCombo1.Text
Unload Me
Else
If Tim = 3 Then
MESSAGE = MsgBox("密码输入错误,请向系统管理员查询!", 0, "")
If MESSAGE = vbOK Then End
End If
If Text2.Text <> rs1.Fields("密码") Then
MsgBox ("密码错误,请重新输入密码!")
Tim = Tim + 1
Text2.SetFocus
End If
End If
Else
Load frm_main
frm_main.Show
Unload Me
End If
rs1.Close
End Sub
Private Sub Command2_Click()
End
End Sub运行的时候老是出现如下的错误:
实时错误'3001':参数类型不正确,或在不可以接受的范围之内,或与其他参数冲突。
vb我也是刚学,怎么也搞不定,请高手指点下
rs1.Open "select * from 用户表_xx044_19 where 用户名='" & DataCombo1.BoundText & "'", Cnn, adOpenKeyset, adLockOptimistic
这一行有错误
2.这一行上面加一行:rs1.cursorlocation=aduseclient
这句错了
改成Dim rs1 As Recordset
在Form_load()里写
rs1=new ADODB.Recordset