上面错了 "select * from 表 where ltrim(rtrim(字段))='" & trim(公共变量)& "'"
"select * from 表 where 字段 ='" & trim(公共变量)& "'"
可以这样: "select * from 表 where 字段 =" & trim(公共变量), 以下为一个例子: re10.Open "select* from bill_night where order_no=0 and room_no = " & xx, connstr, adOpenDynamic, adLockOptimistic ‘XX为变量
VB中的SQL语句不和数据库中的一样,格式改了,要好多的引号: "select * from 表 where 字段 ='" & trim(公共变量)& "'"本人有些想不通为什么要这么多的引号? 特别是'" & trim(公共变量)& "'这一部分的双引号和单引号各有什么作用?? 有谁能详细说明它们的作用吗?
dim conn as new adodb.connection dim res as new adodb.recordset conn.open "your connectionstring" res.open "select * from <yourtablename> where 条件表达式",连接变量,打开游标类型,打开方式
"select * from 表 where ltrim(rtrim(字段))='" & trim(公共变量)& "'"
"select * from 表 where 字段 =" & trim(公共变量),
以下为一个例子:
re10.Open "select* from bill_night where order_no=0 and room_no = " & xx, connstr, adOpenDynamic, adLockOptimistic
‘XX为变量
"select * from 表 where 字段 ='" & trim(公共变量)& "'"本人有些想不通为什么要这么多的引号?
特别是'" & trim(公共变量)& "'这一部分的双引号和单引号各有什么作用??
有谁能详细说明它们的作用吗?
dim res as new adodb.recordset
conn.open "your connectionstring"
res.open "select * from <yourtablename> where 条件表达式",连接变量,打开游标类型,打开方式