我是一个新手,我做了一个登陆窗口,代码如下:
Dim objRs As ADODB.Recordset
Dim intLogTimes As Short
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' On Error GoTo DealError
intLogTimes = intLogTimes + 1
If intLogTimes > 3 Then
MsgBox("超过限制登录次数,将退出登录!", MsgBoxStyle.Critical, "系统登录")
Me.Close()
Exit Sub
End If
'检查是否存在指定身份用户
objRs.MoveFirst()
objRs.Find("username='" & txtusername.Text & "'")
If objRs.EOF Then
MsgBox("用户名错误!", MsgBoxStyle.OKOnly + MsgBoxStyle.Critical, "系统登录")
txtusername.Focus()
Else
'检查密码是否正确
If objRs.Fields("password").Value <> txtPassWord.Text Then
MsgBox("口令错误!", MsgBoxStyle.OKOnly + MsgBoxStyle.Critical, "系统登录")
txtPassWord.Focus()
Else
'检查身份是否正确
If objRs.Fields("userlx").Value <> cmbStatus.Text Then
MsgBox("身份错误!", MsgBoxStyle.OKOnly + MsgBoxStyle.Critical, "系统登录")
cmbStatus.Focus()
Else
MsgBox("登录成功!", MsgBoxStyle.Information, "系统登录")
Me.Close()
Dim frmmain As Frmmain
frmmain.Show()
End If
End If
End If
Exit Sub
DealError:
MsgBox("程序执行出错,错误信息如下:" & vbCrLf & Err.Description)
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strsql As Object
Dim strcn As Object
' On Error GoTo DealError
Dim objCn As New ADODB.Connection
'建立数据库连接
'UPGRADE_WARNING: 未能解析对象 strcn 的默认属性。
strcn = "Integrated Security=SSPI;Packet Size=4096;Data Source=LGY-AB28DBE14A4;Tag with column collation when possible=False;Initial Catalog=kaoshixitong;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider=SQLOLEDB.1;Workstation ID=LGY-AB28DBE14A4;Use Encryption for Data=False;"
objCn.ConnectionString = strcn
objCn.Open()
objRs = New ADODB.Recordset
objRs.ActiveConnection = objCn
objRs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
strsql = "SELECT * FROM yhxx"
objRs.Open(strsql)
objRs.let_ActiveConnection(Nothing)
objCn.Close() '关闭数据库连接
objCn = Nothing '释放连接对象
'设置默认身份
cmbStatus.SelectedIndex = 0
Exit Sub
DealError:
MsgBox("程序执行出错,错误信息如下:" & vbCrLf & Err.Description)
End Sub
End Class
运行时总是提示:参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
如何解决啊??