问题一:
datagrid表头的序号在筛选后就乱了,怎么重新生成呢?
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
4 6081 04 S21 J1B 21%
5 6080 05 S12 J1B 33%
筛选后就变成了
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
5 6080 05 S12 J1B 33%
我想让它自动编号为:
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
4 6080 05 S12 J1B 33%
该如何实现?
问题二:
统计出Group列下S1的记录个数显示到Label1中,请各位高手帮忙解答.
datagrid表头的序号在筛选后就乱了,怎么重新生成呢?
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
4 6081 04 S21 J1B 21%
5 6080 05 S12 J1B 33%
筛选后就变成了
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
5 6080 05 S12 J1B 33%
我想让它自动编号为:
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
4 6080 05 S12 J1B 33%
该如何实现?
问题二:
统计出Group列下S1的记录个数显示到Label1中,请各位高手帮忙解答.
ADODC2.Recordset.MoveLast
ADODC2.Recordset.MoveFirst
Label1.Caption = ADODC2.Recordset.RecordCount
Label1.Caption = ADODC2.Recordset.RecordCount
不能解决我的问题,
如果我需要统计datagrid2中的"S1"记录数量呢?
NO Tester ID Cell ID Group Mode Yield
1 6084 01 S11 J1B 25%
2 6083 02 S12 J1B 5%
3 6082 03 S13 J1B 45%
4 6081 04 S21 J1B 21%
5 6080 05 S12 J1B 33%
那sql语句就是:select count(*) as 记录数 from AllZone where [group] = 'S1'
如果是S1打头的记录数:select count(*) as 记录数 from AllZone where [group] like 'S1%'
如果是含有S1的记录数:select count(*) as 记录数 from AllZone where [group] like '%S1%'
以上结果中的【记录数】就是你要的结果。
如果是绑定给了Adodc2,那就这个记录数的值就是:ADODC2.Recordset!记录数
a.Tester ID,
a.Cell ID,
a.Group,
a.Mode,
a.Yield
into #temp
from AllZone where [group] like 'S1%'
go
select * from #temp
go
drop table #temp
go
楼上的code我加了个文字特效,显示不对,用这个。
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data\mdb.mdb;Persist Security Info=False"
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from AllZone where [group] like 'S1%'"
Set DataGrid2.DataSource = Adodc2
datagrid2.columns(5).numberformat="#0%"
后面加上
ADODC2.Recordset.MoveLast
ADODC2.Recordset.MoveFirst
Label1.Caption = ADODC2.Recordset.RecordCount
得到的就是你需要的记录数。如果你的条件改变了,方法当然也要变。这要看你的需求究竟是什么了。
select RANK() OVER (ORDER BY Cell ID ) AS 序号,
Tester ID,
Cell ID,
Group,
Mode,
Yield
from AllZone where [group] like 'S1%'
另外字段名称别在中间加空格,比如你的Cell ID字段,写成Cell_ID较妥当。
我用的是Access 2003,没有用SQL,应怎么做呢?
不好意思,可能是我的问题没有描述清楚,现重新说明如下:
我的最终目的是:
with datagrid1
.row=0
.col=3
.text=datagrid5中的group=S1%记录数量
end withwith datagrid1
.row=1
.col=3
.text=datagrid5中的group=S2%记录数量
end with
红色字体部分不知如何写代码了,请帮忙,谢谢!
S1, xx
S2, yy
...实际上方法很多,看怎样适合你的操作过程。
谢谢您!
我想要得到的结果就是10楼的描述,我试了11楼的做法,但如何保存和读取这个记录集呢?
由于我对数据库也是刚刚开始入手,很多地方都还不知道,属于那种边做边学习的.
请详细说明一下具体的做法吗?如有VB code那是最好不过了.