LostWater 发表于 2008-5-16 00:21

VB 2008 DataGridView 变量查询问题

使用添加查询选项,用平时的SQL语句写法,select * from jewels where name like '" & iId & "%' ,,,,为什么查询结果会是空,,在formload里有写,iId="d"
我把变量换成常量就正常,返回我要的结果
select * from jewels where name like 'd%'

语法问题?还是?

LostWater 发表于 2008-5-17 15:45

,MD!!!MSDN上都没人回答

ReiFukai 发表于 2008-5-17 16:53

\"\'\"&lid&\"%\'\"

hein 发表于 2008-5-19 00:07

sql_str=\"select * from jewels where name like \'d%\'\"
sql_str=\"select * from jewels where name like \'\" & iId & \"%\'\"

貌似没问题吧,把“\'”换成 chr(34)看看?~~~

iken 发表于 2008-5-19 04:25

form_load里面在iId=\"d\"之后有刷新吗?

canto 发表于 2008-5-22 17:23

把iId=\"d\"挪到select * from jewels where name like \'\" & iId & \"%\'
上面一行,会出现正常还是空白的结果?

很有可能是SQL query在formload变量数值确定之前就已经被执行了。
页: [1]
查看完整版本: VB 2008 DataGridView 变量查询问题