+ -
当前位置:首页 → 问答吧 → 小弟对vb一无所知 做课程设计时遇到了问题 望各位好心人帮帮忙

小弟对vb一无所知 做课程设计时遇到了问题 望各位好心人帮帮忙

时间:2011-12-12

来源:互联网

登录窗口代码如下
Option Explicit
Dim cnt As Integer '记录确定次数

Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(txtuser.Text) = "" Then '判断输入的用户名是否为空
  MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
  txtuser.SetFocus
Else
  sql = "select * from 系统管理 where 用户名='" & txtuser.Text & "'"
  rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
  If rs_login.EOF = True Then
  MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""
  txtuser.SetFocus
  Else '检验密码是否正确
  If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then
  userID = txtuser.Text
  userpow = rs_login.Fields(2)
  rs_login.Close
  Unload Me
  MDIForm1.Show
  Else
  MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
  txtpwd.SetFocus
  End If
  End If
End If
cnt = cnt + 1
If cnt = 3 Then
  Unload Me
End If
Exit Sub
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
  "data source=E:\图书管理系统\book.mdb"
conn.Open connectionstring
cnt = 0
End Sub
运行时总是提示至少有一个参数没有被指定值
点击调试后提示
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
这句有问题 
请问到底哪里出错了
应该怎么改  
谢谢各位了

作者: date123654   发布时间: 2011-12-12

VB code

Option Explicit
Dim cnt As Integer '记录确定次数
Public Conn As New ADODB.Connection
 

作者: cnuser1   发布时间: 2011-12-12