求助:关于将listview1中的所有内容写入到数据库中,并能安原来的顺序读出来!就是listview1中
每行都是
           列1                        列2
行1  [2005-10-24 10:12:13]   [2005-10-25  10:15:12]
行2  [2005-10-26 10:12:13]   [2005-10-26  10:15:12]将它们存储到数据库中,并按现在的顺序读出来!情大家帮帮忙,给个代码!

解决方案 »

  1.   

    为什么不开始把数据存到数据库里,然后在listview里显示出来呢?
      

  2.   

    循环insert into 
    把每条记录加序号就是,读出按序号排序就是啊~
      

  3.   

    '写入(假设有表Table (id,f1,f2))
    dim Mitem as Listitem
    dim i as integer
    dim str as string
    dim cnn as new adodb.connection
    cnn.open .........
     for i=0 to Listview1.listitems.count-1
        set Mitem=Listview1.Listitems(i)
        str=cstr(i) 
        str=str+Mitem.caption
        str=str+","+Mitem.subitems.item(1).text
        cnn.execute "insert into table select "+str
    next
    cnn.close
    '读出
    dim Mitem as Listitem
    dim Rst as new adodb.recordset
    dim cnn as new adodb.connection
    dim i as integer
    cnn.open .........rst.open "select * from table order by id"
    if rst.eof then
      do while not rst.eof
         set mitem=Listview1.listitems.add (i,"K"+rst(1)&"",rst(1)&"")
         mitem.subitems(1)=rst(2)&""
         rst.movenext
      loop
    end if
    rst.close
      

  4.   

    '这句改一下
    str=str+","+Mitem.subitems.item(1).text
    '改
    str=str+","+Mitem.subitems(1)
      

  5.   

    '再改
    rst.open "select * from table order by id"
    '改
    rst.open "select * from table order by id",cnn,1,2