您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



各位专家看看帮我数据更新的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


各位专家看看帮我数据更新的问题
发表于:2007-08-01 13:32:01 楼主
各位专家看看帮我数据更新的问题


private   sub   printgrid()

      on   error   goto   err_init

      dim   ssql   as   string
     
      isprinting   =   true
            ssql   =   "select   *   from   ptcust   order   by   site,dtype,id "
             
      dim   db   as   connection,   ef   as   recordset
      dim   tmpef   as   recordset
      set   db   =   createobject( "adodb.connection ")
      set   ef   =   createobject( "adodb.recordset ")
      set   tmpef   =   createobject( "adodb.recordset ")
              db.open   constr
              if   ef.state   <>   adstateclosed   then   ef.close
              ef.open   ssql,   db,   adopenkeyset,   adlockreadonly,   adcmdtext
     
      dim   sdupsite   as   string
      dim   xtmptop   as   long                                                 '重复高度
              sdupsite   =   " "
      set   tmpef   =   ef.clone                                               '克隆一个相同的记录集

...........中间部分正确..............
                              '删除当前记录
                                tmpef.delete   adaffectcurrent       这部分会提示当前记录集不支持更新,怎样修改可以支持更新                                
                                tmpef.movenext
发表于:2007-08-01 13:41:391楼 得分:0
ef.open   ssql,   db,   adopenkeyset,   2,   adcmdtext
可能是2,不过你可以试一试,1,2,3看哪个行
发表于:2007-08-01 13:43:182楼 得分:0
adlockreadonly,只读呢
发表于:2007-08-01 20:05:153楼 得分:0
adopenkeyset,   adlockreadonly   我全试了,
只有ef.open   ssql,   db,   1,   1,   adcmdtext或ef.open   ssql,   db,   3,   1,   adcmdtext       记录集支持set   tmpef   =   ef.clone。
  但是不支持tmpef.delete   adaffectcurrent     记录集更新。

现在想办法让他能够删除当前记录,问题就解决了。
请各位帮帮我。
发表于:2007-08-01 20:15:094楼 得分:0
换个逻辑,用db.excute   做吧
sql= "delete   from   ... "
发表于:2007-08-01 20:26:185楼 得分:0
表里有重复记录,而且tmpef   =   ef.clone之后是把个字段的当前记录处理后再把他删除
发表于:2007-08-01 20:27:536楼 得分:0
以下是全部语句:


private   sub   printgrid()

      on   error   goto   err_init

      dim   ssql   as   string
     
      isprinting   =   true
     
    '按每餐桌打印,先点先打
      ssql   =   "select   *   from   ptcust   order   by   site,dtype,id "
             
      dim   db   as   connection,   ef   as   recordset
      dim   tmpef   as   recordset
      set   db   =   createobject( "adodb.connection ")
      set   ef   =   createobject( "adodb.recordset ")
      set   tmpef   =   createobject( "adodb.recordset ")
              db.open   constr
              if   ef.state   <>   adstateclosed   then   ef.close
              ef.open   ssql,   db,   3,   1,   adcmdtext
     
      dim   sdupsite   as   string
      dim   xtmptop   as   long                                                 '重复高度
              sdupsite   =   " "
      set   tmpef   =   ef.clone                                               '克隆一个相同的记录集

              if   not   (tmpef.eof   and   tmpef.bof)   then
                    do   while   not   tmpef.eof()
                          '打印当前的列表
                            'if   printsheet(tmpef( "id "))   =   false   then
                                  '打印不正常时退出。
                            '         exit   do
                            'end   if
                            '相同座位时不重复打印
                              if   sdupsite   <>   tmpef( "site ")   then
                                    if   sdupsite   <>   " "   then
                                          printer.line   (xsmallleft,   xsmalltop   +   18   +   xtmptop)-(xsmallleft   +   70,   xsmalltop   +   18   +   xtmptop),   2,   bf
                                          printer.currentx   =   xsmallleft   +   40
                                          printer.currenty   =   xsmalltop   +   20   +   xtmptop
                                          printer.print   "时间: "   &   time
                                          printer.enddoc
                                    end   if
                                    xtmptop   =   0
                                    sdupsite   =   tmpef( "site ")
                                    printer.scalemode   =   6         '厘米
                                    printer.font   =   "黑体 "
                                    printer.fontbold   =   true
                                    printer.fontsize   =   "10 "
                                    printer.currentx   =   xsmallleft
                                    printer.currenty   =   xsmalltop
                                    printer.print   "座位: "   &   tmpef( "site ")
                                    printer.currentx   =   xsmallleft   +   40
                                    printer.currenty   =   xsmalltop
                                    printer.print   "操作员: "   &   tmpef( "doper ")
                                    printer.font   =   "宋体 "
                                    printer.fontsize   =   "9 "
                                    printer.currentx   =   xsmallleft
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "菜名 "
                                    printer.currentx   =   xsmallleft   +   15
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "单位 "
                                    printer.currentx   =   xsmallleft   +   23
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "单价 "
                                    printer.currentx   =   xsmallleft   +   32
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "数量 "
                                    printer.currentx   =   xsmallleft   +   39
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "加工 "
                                    printer.currentx   =   xsmallleft   +   46
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "金额 "
                                    printer.currentx   =   xsmallleft   +   55
                                    printer.currenty   =   xsmalltop   +   6
                                    printer.print   "菜分类 "
                                end   if
                                printer.currentx   =   xsmallleft
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "name ")
                                printer.currentx   =   xsmallleft   +   18
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "unit ")
                                printer.currentx   =   xsmallleft   +   22
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "price ")
                                printer.currentx   =   xsmallleft   +   32
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "quanty ")
                                printer.currentx   =   xsmallleft   +   40
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "jgf ")
                                printer.currentx   =   xsmallleft   +   44
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "amos ")
                                printer.currentx   =   xsmallleft   +   55
                                printer.currenty   =   xsmalltop   +   12   +   xtmptop
                                printer.print   tmpef( "dtype ")
                              '删除当前记录
'                                 returnrec.cursorlocation   =   aduseclient
                                tmpef.delete   adaffectcurrent
                                tmpef.movenext
                                xtmptop   =   xtmptop   +   6
                    loop
                end   if
                if   sdupsite   <>   " "   then
                        printer.line   (xsmallleft,   xsmalltop   +   18   +   xtmptop)-(xsmallleft   +   70,   xsmalltop   +   18   +   xtmptop),   2,   bf
                        printer.currentx   =   xsmallleft   +   40
                        printer.currenty   =   xsmalltop   +   20   +   xtmptop
                        printer.print   "时间: "   &   time
                        printer.enddoc
                end   if
                ef.close
                tmpef.close
                set   ef   =   nothing
                set   tmpef   =   nothing
                db.close
                set   db   =   nothing
                isprinting   =   false
               
                exit   sub


快速检索

最新资讯
热门点击