出现3061号错误:"缺少参数,期望是"
编号:QA003808
建立日期: 2001年1月28日 最后修改日期:2001年1月28日
所属类别:
王帅:
操作系统: WIN98
编程工具: VB6.0
问题: 你好!
我在将当前Form上CmbCustomer列表中已被选取项作为查询条件时,出现错误,程序如下:
(数据库文件无问题)
dim Strsql as String
dim db as DataBase
dim rs as Recordset
set db=opendatabase(......)
Strsql="Select * from tblcustomer where CustomerName=" & CmbCustomer.list(CmbCustomer.listindex)
set rs=db.open(Strsql) '运行到此出现错误
出现<3061>号错误提示如下:
"缺少参数,期望是"
请帮手多谢!
水平: 刚入门
回答:
你的CustomerName显然是一个字符串类型,这样你的SQL语句就有问题了,例如cmbCustomer.List(0)为"john",那么SQL语句就成了:
Select * from tblcustomer where CustomerName=john
这样肯定不符合语法要求。VB会把john看做一个没有指定的参数,所以会报这样的错误。正确的SQL语句应该是:
Select * from tblcustomer where CustomerName='john'
倒推回去,你的语句应该是
Strsql="Select * from tblcustomer where CustomerName='" & CmbCustomer.list(CmbCustomer.listindex) + "'"
此问题由李海回答。
| |
|
|
| |
|
|