200分! 200分! 200分!(200分)

  • 主题发起人 主题发起人 sheng
  • 开始时间 开始时间
可以建一个临时表,增加一个自增字段。
 
如何一一对应?
 
你的table应当有一个key吧?
例子:table1.key1是你的key, 类型为varchar(15)

BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_table1
(
ID int NOT NULL IDENTITY (1, 1),
key1 varchar(15) NULL
) ON "default"
GO
IF EXISTS(SELECT * FROM dbo.table1)
EXEC('INSERT INTO dbo.Tmp_table1(key1)
SELECT key1 FROM dbo.table1 TABLOCKX')
GO
COMMIT


然后query:='select Tmp_table1.ID,table1.* from table1,tmp_table1 where' +
' table1.key1=Tmp_table1.key1 and Tmp_table1.ID>' +
inttostr((x-1)*10) + ' and Tmp_table1.ID<=' + inttostr(x*10) +
' order by Tmp_table1.ID';


 
不好意思,我只看明白一部分。
请详细说明。
 

例子:table1.key1是你的key, 类型为varchar(15)

BEGIN TRANSACTION //开始事务
CREATE TABLE dbo.Tmp_table1
(
ID int NOT NULL IDENTITY (1, 1),
key1 varchar(15) NULL
) ON "default"
GO //建立一个临时表,含自增字段ID和你TABLE中的KEY字段
IF EXISTS(SELECT * FROM dbo.table1)
EXEC('INSERT INTO dbo.Tmp_table1(key1)
SELECT key1 FROM dbo.table1 TABLOCKX')
GO //把表中KEY字段内容添加到临时表中,同时自增字段生成。
//顺序可以由SELECT语句中加ORDER BY 定
COMMIT //开始执行事务


然后query:='select Tmp_table1.ID,table1.* from table1,tmp_table1 where' +
' table1.key1=Tmp_table1.key1 and Tmp_table1.ID>' +
inttostr((x-1)*10) + ' and Tmp_table1.ID<=' + inttostr(x*10) +
' order by Tmp_table1.ID';
 
1stclass中的dbtreeview好象可以
http://hansxia.zb169.net/vcls/1stclassPro_d4.exe
size:2689025
sn:1STCLASS2B259729
 
用TCLIENTDATASET控件,将其PACKETRECORD属性设为10即可
 
ODBC不是本身就能提供这种机制吗?!
参见MSDN中SQLBindParameter()中的 Row-Wise Parameter Binding
以及How to use rowset binding (ODBC)如下:
How to use rowset binding (ODBC) To use column-wise binding

For each bound column
Allocate an array of R (or more) column buffers to store data values, where R is number of rows in the rowset.
Optionally, allocate an array of R (or more) column buffers to store data lengths.
Call SQLBindCol to bind the column抯 data value and data length arrays to the column of the rowset.
Call SQLSetStmtAttr to set the following attributes:
Set SQL_ATTR_ROW_ARRAY_SIZE to the number of rows in the rowset (R).
Set SQL_ATTR_ROW_BIND_TYPE to SQL_BIND_BY_COLUMN.
Set the SQL_ATTR_ROWS FETCHED_PTR attribute to point to a SQLUINTEGER variable to hold the number of rows fetched.
Set SQL_ATTR_ROW_STATUS_PTR to point to an array[R] of SQLUSSMALLINT variables to hold the row-status indicators.
Execute the statement.
Each call to SQLFetch or SQLFetchScroll retrieves R rows and transfers the data into the bound columns.
To use row-wise binding

Allocate an array[R] of structures, where R is the number of rows in the rowset. The structure has one element for each column, and each element has two parts:
The first part is a variable of the appropriate data type to hold the column data.
The second part is a SQLINTEGER variable to hold the column status indicator.
Call SQLSetStmtAttr to set the following attributes:
Set SQL_ATTR_ROW_ARRAY_SIZE to the number of rows in the rowset (R).
Set SQL_ATTR_ROW_BIND_TYPE to the size of the structure allocated in step 1.
Set the SQL_ATTR_ROWS_FETCHED_PTR attribute to point to a SQLUINTEGER variable to hold the number of rows fetched.
Set SQL_ATTR_PARAMS_STATUS_PTR to point to an array[R] of SQLUSSMALLINT variables to hold the row-status indicators.
For each column in the result set, call SQLBindCol to point the data value and data length pointer of the column to their variables in the first element of the array of structures allocated in step 1.
Execute the statement.
Each call to SQLFetch or SQLFetchScroll retrieves R rows and transfers the data into the bound columns.
See Also
How to use cursors (ODBC) SQLBindCol
How Cursors Are Implemented SQLSetStmtAttr
Using Default Result Sets SQLFetchScroll


 
呵呵,用MIDAS来实现,将ClientDataset的Packetsize属性值设置为10就行了。
如想一次取100,就设置为100。不姓自己式了!
 
关于页式访问数据库,我的经验是用Delphi辅助。虽然有些数据库系统提供了
类似的功能,但我建议你不要用,因为不是标准。我认为最有效的办法是:在
系统启动时建立一个内存索引,然后随着你操作这个库来动态地维护它,在建
立动态查询前使用为个索引。你知道,其实这个索引占用很少资源的。你可以
用SELECT * FROM MYTABLE WHERE ID>=%d AND ID<%d来执行,既有速度又有简
便性。
 
哗!一下子来了这么多的大师,又出了这么好主意,我真高兴!!!

我想问一下barton:“内存索引”建立的详细方法。

另问“视窗王子”:E文太难看明白,能否用中文解释一下?
 
继续,还是抽奖?
 
大家好!
终于又能到这里了(这里的网站实在是太太太太难上了)!!!!!!
现在有个难道:这分数怎么分啊!!!!!
实在是太多谢大家了,但我又不能每人给100分啊。
我想还是大家来评分又或者由栏目主持人来评一评吧!

谢谢!!!谢谢!!!
 
您老还是自己来吧,看哪个你比较懂,对你比较有帮助吧:-)
 
这样的问题用那个格子不是很容易吗?
放一个格子让它只能显示10个记录,OK。:)
要看其它的自己拉滚动条。:)
 
好象在ansi sql 语法里面就有一次从第X开始传回Y行的
语法,是连SELECT一起用。具体不记得了,哪位前辈能
指教一下呢?
 
让大家久等了,现在来个太公分猪肉人人有份!
 
多人接受答案了。
 
后退
顶部