在线等待(SQL语句问题)

ntz 2003-05-13 01:56:23
我用的是ACCESS数据库,有两个表:TRAP和TYPE
用以下的语句查询就出错
dim source as date
dim numberss as integer
source=03-5-7
numberss=50
Set rs= db.OpenRecordset("select trap.msg,type.index from trap,type where
trap.datetime=source and type.index=numberss")

在数据库中,日期型的字段怎样用变量操作呀,还有整型,字符串等等,请赐教
...全文
41 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
vzxq 2003-05-13
  • 打赏
  • 举报
回复
你先在ACCESS中 用向导生成查询。把生的的SQL 语句复制到VB中,这样一定不会出错。
fengxie 2003-05-13
  • 打赏
  • 举报
回复
Set rs= db.OpenRecordset("select trap.msg,type.index from trap,type where
trap.datetime=#" & source & "# and type.index=" & numberss & ")
cotaxyp 2003-05-13
  • 打赏
  • 举报
回复
to: qvbiiss(qvbiiss)
你的答案没有参考价值!
qvbiiss 2003-05-13
  • 打赏
  • 举报
回复
Data1.RecordSource = "select * from clinetdataf where companyname ='" & Publicstringc + "'"
可以看看这段代码没错的.
cotaxyp 2003-05-13
  • 打赏
  • 举报
回复
哦!你后面那个字段名称,在select 和 from 之间没有写出来,所以会有这样的提示!把它加进去!
cotaxyp 2003-05-13
  • 打赏
  • 举报
回复
“参数不足,期待是1”
看一下你的数据库表中是否有这个字段,或者是拼错了!仔细检查一下!
cotaxyp 2003-05-13
  • 打赏
  • 举报
回复
也可以把日期变量当作字符串来处理!
ntz 2003-05-13
  • 打赏
  • 举报
回复
还是出错“参数不足,期待是1”
chenyu5188 2003-05-13
  • 打赏
  • 举报
回复
同意sxs69() 的,用变量传入。
ntz 2003-05-13
  • 打赏
  • 举报
回复
类型不匹配呀
sxs69 2003-05-13
  • 打赏
  • 举报
回复
dim source as date
dim numberss as integer
source=#03-5-7#
numberss=50
Set rs= db.OpenRecordset("select trap.msg,type.index from trap,type where
trap.datetime= " & source & "and type.index= " & numberss &"")
qbilbo 2003-05-13
  • 打赏
  • 举报
回复
Set rs= db.OpenRecordset("select trap.msg,type.index from trap,type where
trap.datetime=#"+source+"# and type.index=numberss")

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧