首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

小弟我到底哪里错了? 数据库

2012-02-01 
我到底错哪了? 数据库高手请进!联合查询语句没错,我已经能够查询.但我想把查询保存到表DJ3时,报错!搞不懂!

我到底错哪了? 数据库高手请进!
联合查询语句没错,我已经能够查询.但我想把查询保存到表DJ3时,报错!搞不懂!
语句如下:
sql   =   "insert   into   dj3(bzw,xtbh   ,xm   ,   gxfl   ,fsdx,sqsy   ,sqje,   djwp   ,fssj   ,sqsj   )   select   bzw,xtbh   ,xm   ,   gxfl   ,fsdx,sqsy   ,sqje,   djwp   ,fssj   ,sqsj     from   sqdjb1   where   xm   =   ' "   +   Text1.Text   +   " '   or     (fssj   between     #   "   &   Format(DTPicker1.Value,   "yyyy-M-dd ")   &   "   #       and         # "   &   Format(DTPicker2.Value,   "yyyy-M-dd ")   &   "#   )     union   all     select   *   from     sqdjb2   where     xm   =   ' "   +   Text1.Text   +   " '   or     (fssj   between     #   "   &   Format(DTPicker1.Value,   "yyyy-M-dd ")   &   "   #       and         # "   &   Format(DTPicker2.Value,   "yyyy-M-dd ")   &   "#     "
    cnn.Execute   sql

[解决办法]
ssql= "insert into dj3(bzw,xtbh ,xm , gxfl ,fsdx,sqsy ,sqje, djwp ,fssj ,sqsj ) "
ssql=ssql & vbcrlf & "select bzw,xtbh ,xm , gxfl ,fsdx,sqsy ,sqje, djwp ,fssj ,sqsj "
ssql=ssql & vbcrlf & "from sqdjb1 where xm = ' "& text1.text & " ' or (fssj between '1999-02-02 ' and '1999-02-02 ') "
ssql=ssql & vbcrlf & "union all "
ssql=ssql & vbcrlf & "select * "
ssql=ssql & vbcrlf & "from sqdjb2 where xm = ' "& text1.text & " ' or (fssj between '1999-2-01 ' and '1999-02-02 ') "
--表sqdjb2最好写全字段. 写出SQL语句后再加条件.

热点排行