您的位置:程序门 -> vb -> 基础类



简单的问题,请各位看下 (系列二——加分贴)


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


简单的问题,请各位看下 (系列二——加分贴)[已结贴,结贴人:snowwolf2818]
发表于:2007-01-06 17:27:14 楼主
3列10行的数据,我把第一列列宽缩小到0,不想在那列添加数据,背景不好看
with   mshflexgrid1
          .cols   =   4
          .rows   =   11
end   with
j   =   1
do   until   rs.eof
          for   i   =   1   to   rs.fields.count   -   1
            mshflexgrid1.textmatrix(j,   i)   =   rs.fields(i-   1).value
          next   i
          rs.movenext
        j   =   j   +   1
loop  

错误语句:
  mshflexgrid1.textmatrix(j,   i)   =   rs.fields(i   -   1).value
出现问题:超出范围

只要正解者就给100,不够另外开贴发分!!
发表于:2007-01-06 17:45:391楼 得分:0
这,这是vc/mfc???

兄弟.你的帖子,发错地方了把?
发表于:2007-01-06 18:30:302楼 得分:9
顶下
发表于:2007-01-06 18:31:133楼 得分:0
╭═══╮ ╭═══╮ ╭══════╮         
╰╮ ╭╯ ╰╮ ╭╯ ╰╮ ╭══╮╰╮        
    ║ ║   ║ ║   ║ ║  ╰╮╰╮       
    ║ ║   ║ ║   ║ ║   ║ ║       
    ║ ║   ║ ║   ║ ║   ║ ║       
    ║ ║   ║ ║   ║ ║  ╭╯╭╯       
    ║ ║   ║ ║   ║ ╰══╯╭╯        
    ║ ║   ║ ║   ║ ╭═══╯         
    ║ ║   ║ ║   ║ ║             
    ║ ║   ║ ║   ║ ║             
    ║ ║   ║ ║   ║ ║             
    ╰╮╰╮ ╭╯╭╯   ║ ║             
     ╰╮╰═╯╭╯   ╭╯ ╰╮            
      ╰═══╯    ╰═══╯
发表于:2007-01-06 20:58:114楼 得分:1
with   mshflexgrid1
          .cols   =   4
          .rows   =   11
end   with
定义了4列11行,你的数据集rs中的列或行应该有超出范围才对
试着把cols及rows的值改大些
发表于:2007-01-06 21:33:295楼 得分:40
with   mshflexgrid1
          .cols   =   4
          .rows   =   rs.recordcounts+1
end   with
j   =   1
do   until   rs.eof
          for   i   =   1   to   rs.fields.count   -   1
            mshflexgrid1.textmatrix(j,   i)   =   rs.fields(i-   1).value
          next   i
          rs.movenext
        j   =   j   +   1
loop  
发表于:2007-01-06 23:00:046楼 得分:40

with   mshflexgrid1
j   =   1
          .cols   =   4
          .rows   =   rs.recordcounts+1
          do   until   rs.eof
          for   i   =   1   to   rs.fields.count   -   1
            textmatrix(j,   i)   =   rs.fields(i-   1).value
          next   i
          rs.movenext
        j   =   j   +   1
loop  
end   with
发表于:2007-01-08 07:56:177楼 得分:0
楼上两位:cheeringsoft()   (   )   信誉:+     nhotnhot()   (   )   信誉:100         blog  
目前根据你们的思路该成如下代码,但是出现的行数太多,本来就10行数据,结果出现了很多行
with   mshflexgrid1
          .cols   =   4
          .rows   =   rs.recordcount   +   1
end   with
j   =   1
do   until   rs.eof
       
          for   i   =   1   to   rs.fields.count   '-   1
                          mshflexgrid1.textmatrix(j,   i)   =   rs.fields(i   -   1).value
          next   i
          rs.movenext
        j   =   j   +   1
loop
发表于:2007-01-08 08:10:528楼 得分:0
而且表头,都没有显示出来,请再帮忙想想办法
发表于:2007-01-08 08:21:059楼 得分:10
rs.movefirst
for   j=1   to   10   '10行
        for   i=1   to   3 '3列
                if   not   rs.eof   then
                        mshflexgrid1.textmatrix(j,   i)   =   rs.fields(i-   1).value      
                end   if
        next   i
        if   not   rs.eof   then  
              rs.movenext  
        else
              exit   for
        end   if
next   j
发表于:2007-01-08 08:30:3410楼 得分:0
cn.connectionstring   =   "provider=microsoft.jet.oledb.4.0;data   source=d:\db2.mdb;persist   security   info=false "
cn.open
新问题:为何不让改成相对路径?
cn.connectionstring   =   "provider=microsoft.jet.oledb.4.0;data   source=.app.path   &   \db2.mdb;persist   security   info=false "
发表于:2007-01-12 12:45:2911楼 得分:0
你的反斜杠错了“/”
cn.connectionstring   =   "provider=microsoft.jet.oledb.4.0;data   source=   app.path   &     /db2.mdb;persist   security   info=false "


快速检索

最新资讯
热门点击