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



问个简单问题


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


问个简单问题[已结贴,结贴人:]
发表于:2007-01-30 14:56:45 楼主
strcon1   =   "provider=sqloledb.1;password=linux;persist   security   info=true;user   id=system;initial   catalog=shopdata;data   source=192.168.0.2 "
                con1.open   strcon1
                set   rs1   =   new   adodb.recordset
                strsql1   =   "select   posinfo.printername,cancelprint.canceltime,cancelprint.describ   from   cancelprint,posinfo   where   posinfo.posno=cancelprint.printername   and   canceltime> "   +   " ' "   &   oldtime   &   " ' "   +   "and   canceltime < "   +   " ' "   &   now   &   " ' "
                rs1.open   strsql1,   con1
                if   rs1.eof   and   rs1.bof   then
                        count1   =   count1   +   1
                        label55.caption   =   strsql1
                else
                        text7.text   =   label26.caption   +   "   "   +   cstr(rs1.fields(0))   +   "   "   +   cstr(rs1.fields(1))   +   "   "   +   cstr(rs1.fields(2))
                        count1   =   count1   +   1
                end   if
                con1.close
我现在的代码只能显示处一条记录
怎么才能枚举处所有记录呢     有几条显示几条
发表于:2007-01-30 15:09:041楼 得分:0
把语句
                if   rs1.eof   and   rs1.bof   then
                        count1   =   count1   +   1
                        label55.caption   =   strsql1
                else
                        text7.text   =   label26.caption   +   "   "   +   cstr(rs1.fields(0))   +   "   "   +   cstr(rs1.fields(1))   +   "   "   +   cstr(rs1.fields(2))
                        count1   =   count1   +   1
                end   if

改成   do   while   not   rs1.eof  
          '要处理的内容
          loop
发表于:2007-01-30 15:19:222楼 得分:0
else
                        text7.text   =   label26.caption   +   "   "   +   cstr(rs1.fields(0))   +   "   "   +   cstr(rs1.fields(1))   +   "   "   +   cstr(rs1.fields(2))
                        count1   =   count1   +   1
                end   if
我只需要这个部分执行就ok了
发表于:2007-01-30 15:22:373楼 得分:0
do   while   not   rs1.eof
                        text7.text   =   label26.caption   +   "   "   +   cstr(rs1.fields(0))   +   "   "   +   cstr(rs1.fields(1))   +   "   "   +   cstr(rs1.fields(2))
                        count1   =   count1   +   1
rs1.movenext
loop

'前后略去了


快速检索

最新资讯
热门点击