请问各位老大,如何为datagrid 增加行号?

解决方案 »

  1.   

    select (select sum(1) from tb b where b.id<a.id),* from tb a
      

  2.   

    利用临时表:
    1 创建一个临时表,使其有一个自动增加字段:cn.execute "create table tmp(行号 COUNTER, 字段1 TEXT(50), 字段2 DATETIME, ...)"2 将查询数据放到临时表中
    cn.execute "insert into tmp select name as 字段1, mdate as 字段2, ... from table1 where ..."3 从临时表中取得记录集,并绑定到 datagrid :
    rs.open "select 行号, 字段1 as 姓名, 字段2 as 日期, ... from tmp"
    set datagrid.datasource = rs
      

  3.   

    别忘了用完以后:
    cn.execute "drop table tmp"