<%
OleDbConnection
conn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("vt1.mdb"));conn.Open();
OleDbDataReader dr; OleDbCommand com = new OleDbCommand("Select TOP 1 * from ads", conn);dr = com.ExecuteReader();
while (dr.Read()){
Application.Lock();
Application[
"value"] = dr.GetValue(0);Application.UnLock();
}
OleDbDataReader dr2; OleDbCommand com2 = new OleDbCommand("Select * from ads", conn);dr2 = com2.ExecuteReader();
while (dr2.Read()){
Application[
"max"] = dr2.GetValue(0);}
Random myad = new Random(); OleDbDataReader dr3; OleDbCommand com3 = new OleDbCommand("Select * from ads where adid="+myad.Next((int)Application["value"],(int)Application["max"])+"", conn);dr3 = com3.ExecuteReader();
while (dr3.Read()){
Response.Write(dr3.GetString(1));
}
%>
0th column in my database is adid,1th col is adname...You can develop better with trying

Join the conversation! Your thoughts help the community grow.