数据库连接问题
Private Sub Command1_Click()Dim conn As adodb.Connection
Dim cmd As adodb.Command
Dim par As adodb.Parameter
Dim rst As adodb.Recordset
Set conn = New adodb.Connection
conn.ConnectionString = "provider=msdasql;driver={sql server};server=2C199ADF99AC402;uid=sa;pwd=;database=school"
conn.Open
Set cmd = New adodb.Command
cmd.ActiveConnection = conn
cmd.CommandType = adCmdText
cmd.CommandText = "select * from student where sno between ? and ?"
Set par = cmd.CreateParameter(, adInteger, adParamInput, Val(Text1.Text))
cmd.Parameters.Append par
Set par = cmd.CreateParameter(, adInteger, adParamInput, Val(Text2.Text))
cmd.Parameters.Append par
Set rst = cmd.Execute()
List1.Clear
List1.AddItem ("学号 姓名 性别 班级")
List1.AddItem ("=======================")
Do While Not rst.EOF
List1.AddItem (rst.Fields(0) + " " + rst.Fields(1) + " " + rst.Fields(2) + " " + rst.Fields(4))
rst.MoveNext
Loop
rst.Close
conn.Close
End Sub
大家帮我看看里面哪里错误了
老出现“实时错误 -2147467259(80004005):
misrosoft ODBC SQL SERVER Driver 默认参数的使用无效”