您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何随机得到Access数据库记录

2026/1/5 21:00:25发布25次查看
由于access 数据库 记录 集缓存的原因,从代码里 得到 access 数据库 随机 记录 是得不到,需要用 随机 sql语句的办法来消除缓存。 下面就是例子: voidpage_load(objectsrc,eventargse) { if(!ispostback) { stringmyconnstring=provider=microsoft.jet.ole
 由于access数据库记录集缓存的原因,从代码里得到access数据库随机记录是得不到,需要用随机sql语句的办法来消除缓存。下面就是例子:
voidpage_load(objectsrc,eventargse)
{
if(!ispostback)
{
stringmyconnstring=“provider=microsoft.jet.oledb.4.0;datasource=”
+server.mappath(”aspxweb.mdb.ascx”);
randomr=newrandom();
intintrandomnumber=r.next(1,1000);
stringsql=“selecttop10idas序号,titleas标题fromdocumentorderbyrnd(”
+(-1*intrandomnumber).tostring()+“*id)”;
oledbconnectionmyconnection=newoledbconnection(myconnstring);
myconnection.open();
oledbcommandcmd=newoledbcommand(sql,myconnection);
oledbdatareaderdr=cmd.executereader();
datagrid1.datasource=dr;
datagrid1.databind();
cmd.dispose();
myconnection.close();
myconnection.dispose();
myconnection=null;
}
}
width=”600px”runat=”server”font-size=”9pt”>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product