用ADO连接的时候想分页,但为什么会提示:对象打开时,不允许操作。 ?
古笑添 2005-06-10 02:37:25 分页代码:
try{
var dbConn=Server.CreateObject("ADODB.Connection");
dbConn.Open("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=data;Data Source=.");
var dbRs=Server.CreateObject("ADODB.Recordset");
dbRs.Open("select * from test",dbConn);
dbRs.CursorType=adOpenStatic;
dbRs.PageSize=3;
CurrentPage=Request("Page");
if (CurrentPage<1){
CurrentPage=1;
if (CurrentPage>dbRs.PageCount)
CurrentPage=dbRs.PageCount;
}
else{
CurrentPage=1;
}
dbRs.AbsolutePage=2;
dbRs.AbsolutePosition=0;
for (var i=0;i<dbRs.PageSize;i++){
Response.Write(dbRs("name"));
dbRs.MoveNext();
}
}
catch(e){
Response.Write(e.description);
}
finally{
dbRs.Close();
dbRs=null;
dbConn.Close();
dbConn=null;
}
请大家指教!
祝大家明天节日过得愉快