标题:adodc的RecordSource加上order by时,Datagrid不能显示全部数据
只看楼主
oioc
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-10-17
 问题点数:0 回复次数:0 
adodc的RecordSource加上order by时,Datagrid不能显示全部数据

在窗体加载时,数据表temp中没有数据,在单击CmdQuery时才插入数据,因为是从多表中取得数据,插入后temp中的数据比较乱,所以在Adodc2.RecordSource中加上order by a1 来让显示在datagrid中的数据按日期排列。但是Adodc2.RecordSource设置成下面这样,datagrid就无法显示数据表temp中按a1排列时的第一行数据,其它都能正常显示出来。把下面的order by a1去掉就能全部正常显示出来。但是这样又很乱,根本没法作为报表输出。
请各位路过的朋友帮忙看下。
Adodc2.RecordSource = "select a1 as 日期,a2 as 方式,a3 as 数量,a4 as 重量,a5 as 单价,a6 as 金额 ,a7 as 付款, a8 as 结欠 from temp order by a1"

下面贴上代码,麻烦各位指正!谢谢!
Private Sub Form_Load()
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & C & ";Persist Security Info=False;Jet OLEDB:Database Password=123"
Adodc2.RecordSource = "select a1 as 日期,a2 as 方式,a3 as 数量,a4 as 重量,a5 as 单价,a6 as 金额 ,a7 as 付款, a8 as 结欠 from temp order by a1"
Adodc2.Refresh
DataGrid1.Columns(0).Width = 1850
DataGrid1.Columns(1).Width = 1800
DataGrid1.Columns(2).Width = 1800
DataGrid1.Columns(3).Width = 1850
DataGrid1.Columns(4).Width = 1850
DataGrid1.Columns(5).Width = 1850
DataGrid1.Columns(6).Width = 1850
DataGrid1.Columns(7).Width = 1850
End Sub


Private Sub CmdQuery_Click()
.
.
.
.
.(中间插入数据,略过……)
Adodc2.Refresh
DataGrid1.Columns(0).Width = 1850
DataGrid1.Columns(1).Width = 1800
DataGrid1.Columns(2).Width = 1800
DataGrid1.Columns(3).Width = 1850
DataGrid1.Columns(4).Width = 1850
DataGrid1.Columns(5).Width = 1850
DataGrid1.Columns(6).Width = 1850
DataGrid1.Columns(7).Width = 1850
DataGrid1.Refresh
End Sub

我把插入到temp表中的其它表的数据全部删掉以后再重新输入数据,用Adodc2.RecordSource = "select a1 as 日期,a2 as 方式,a3 as 数量,a4 as 重量,a5 as 单价,a6 as 金额 ,a7 as 付款, a8 as 结欠 from temp order by a1"
来查询temp表,变成datagrid显示不出排列好的数据的最后一行了。
期待各位高手的指点……

[此贴子已经被作者于2007-10-28 4:39:49编辑过]

2007-10-28 01:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-181324-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.267456 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved