vb中出现实时错误'-2147217904(80040e10) ’ 至少一个参数没有被指定值
下面是我的代码段DimconnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimsqlAsStringDimconnstr...
下面是我的代码段
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim connstr As String
Dim lngTmp As Long
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\项目\vb\BJFLP.mdb;Persist Security Info=False"
sql = "select * from 采购订单 where 货品编号='" & Trim(Text1.Text) & "'"
conn.CursorLocation = adUseClient
conn.ConnectionString = connstr
conn.Open
rs.Open sql, conn, adOpenStatic, adLockOptimistic, -1
'Set rs = conn.Execute(sql)
'rs.Open sql, conn, adOpenStatic, adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "没有此记录"
Else
Label5.Caption = "订单编号"
Text2.Text = rs.Fields(0)
Label6.Caption = "货品编号"
Text3.Text = rs.Fields(1)
End If
提示信息是这句话有问题 rs.Open sql, conn, adOpenStatic, adLockOptimistic, -1
请高手帮我解决一下 展开
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim connstr As String
Dim lngTmp As Long
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\项目\vb\BJFLP.mdb;Persist Security Info=False"
sql = "select * from 采购订单 where 货品编号='" & Trim(Text1.Text) & "'"
conn.CursorLocation = adUseClient
conn.ConnectionString = connstr
conn.Open
rs.Open sql, conn, adOpenStatic, adLockOptimistic, -1
'Set rs = conn.Execute(sql)
'rs.Open sql, conn, adOpenStatic, adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "没有此记录"
Else
Label5.Caption = "订单编号"
Text2.Text = rs.Fields(0)
Label6.Caption = "货品编号"
Text3.Text = rs.Fields(1)
End If
提示信息是这句话有问题 rs.Open sql, conn, adOpenStatic, adLockOptimistic, -1
请高手帮我解决一下 展开
1个回答
展开全部
'连接数据库
conn.Open '(虽然设置了ConnectionString我通常写 conn.Open ConnStr 参数)
If conn.State <> adStateOpen Then
Err.Clear
MsgBox "数据库无法开启,程序退出!检查连接字串ConnStr内容"
Exit Sub
End if
' 1.货品编号属性是字串 2.货品编号属性是数值 (依数据库字段的设置为准)
1. sql = "select * from 采购订单 where 货品编号='" & Trim(Text1.Text) & "'"
2. sql = "select * from 采购订单 where 货品编号=" & cLng(Trim(Text1.Text))
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
'检查 rs 数据集是否出错
If Not rs.State = adStateOpen Then
Err.Clear
MsgBox "rs 数据集没有读取。检查上一行的 sql 字串"
Exit Sub
End If
conn.Open '(虽然设置了ConnectionString我通常写 conn.Open ConnStr 参数)
If conn.State <> adStateOpen Then
Err.Clear
MsgBox "数据库无法开启,程序退出!检查连接字串ConnStr内容"
Exit Sub
End if
' 1.货品编号属性是字串 2.货品编号属性是数值 (依数据库字段的设置为准)
1. sql = "select * from 采购订单 where 货品编号='" & Trim(Text1.Text) & "'"
2. sql = "select * from 采购订单 where 货品编号=" & cLng(Trim(Text1.Text))
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
'检查 rs 数据集是否出错
If Not rs.State = adStateOpen Then
Err.Clear
MsgBox "rs 数据集没有读取。检查上一行的 sql 字串"
Exit Sub
End If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询