vb中至少一个参数没有被指定值
PrivateSubCommand1_Click()DimconnAsNewADODB.ConnectionDimrsAsNewADODB.RecordsetDimStr...
Private Sub Command1_Click()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=phonenumber.mdb;"
Str3 = "Jet OLEDB:Database Password="
conn.Open Str1 & Str2 & Str3
strSQL = "select * from phone where 姓名=" & Text1.Text & ""
rs.Open strSQL, conn, 1, 1
If rs!姓名 = Text1.Text Then
'如果rs!姓名 = Text1.Text说明数据库中有此记录并进行删除操作
'否则给“不存在此记录”的提示信息并关闭数据连接
Text2.Text = rs!长号
Text3.Text = rs!短号
rs.Close
conn.Close
Else
MsgBox ("不存在此联系人!")
Text1.Text = ""
rs.Close
conn.Close
Exit Sub
End If
'以下四条语句的作用是在操作完成后将文本框置空
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
“ rs.Open strSQL, conn, 1, 1”这一行报错,“至少一个参数没有被指定值”
可能是“strSQL = "select * from phone where 姓名=" & Text1.Text & "" ”这一行有错误 展开
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
Str2 = "Data Source=phonenumber.mdb;"
Str3 = "Jet OLEDB:Database Password="
conn.Open Str1 & Str2 & Str3
strSQL = "select * from phone where 姓名=" & Text1.Text & ""
rs.Open strSQL, conn, 1, 1
If rs!姓名 = Text1.Text Then
'如果rs!姓名 = Text1.Text说明数据库中有此记录并进行删除操作
'否则给“不存在此记录”的提示信息并关闭数据连接
Text2.Text = rs!长号
Text3.Text = rs!短号
rs.Close
conn.Close
Else
MsgBox ("不存在此联系人!")
Text1.Text = ""
rs.Close
conn.Close
Exit Sub
End If
'以下四条语句的作用是在操作完成后将文本框置空
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
“ rs.Open strSQL, conn, 1, 1”这一行报错,“至少一个参数没有被指定值”
可能是“strSQL = "select * from phone where 姓名=" & Text1.Text & "" ”这一行有错误 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询