[javascript]代码库
<script language="javascript" runat="server">
var conn=new ActiveXObject("ADODB.Connection");
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("data.mdb");
conn.Open();
var rs = new ActiveXObject("ADODB.Recordset");
rs.LockType=rs.CursorType=1;
//rs.ActiveConnection=conn;
//rs.Source="SELECT id,text FROM [Tree]";
var sql="SELECT id,text FROM [Tree]";
rs.Open(sql,conn);
while (!rs.EOF)
...{
Response.Write(rs("text")+" ");
rs.MoveNext();
}
rs.Close;
rs=null;
conn.Close();
conn=null;
</script>
哦,错了
不要用server.mappath()
可以使用路径。不要用server.mappath()
<script language="javascript" runat="server">
var conn=new ActiveXObject("ADODB.Connection");
conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=myTest.mdb";
conn.Open();
var rs = new ActiveXObject("ADODB.Recordset");
rs.LockType=rs.CursorType=1;
var sql="SELECT * FROM 用户信息表";
rs.Open(sql,conn);
rs.pagesize=5;
rs.absolutepage=1;
document.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#0000FF\" width=\"80%\" align=\"center\"> ");
for (i=0;i<rs.pagesize;i++){
document.write("<tr bgcolor='#FFFFFF' align='center'> <td>"+rs("username")+"</td></tr>")
rs.movenext
}
document.writeln("</table>")
</script>