通过javascript发送http请求php的API接口,php连接数据库并查询结果,最后返回出来
这样javascript就能获取到数据库的数据
// 建立数据库对象var objdbConn = new ActiveXObject("ADODB.Connection")// DSN字符串var strdsn = "DRIVER={Microsoft Access Driver (*.mdb)}DBQ=F:\\ZNZ资料\\检查课件\\javascript课件\\CH12\\Books.mdb"// 打开数据来源objdbConn.Open(strdsn)// 执行SQL的数据库查询var objrs = objdbConn.Execute("SELECT * FROM Book")// 获取区域数目var fdCount = objrs.Fields.Count - 1// 检查是否有记录if (!objrs.EOF){document.write("<table border=1><tr>")// 显示数据库的区域名称for (var i=0i <= fdCounti++)document.write("<td><b>" + objrs.Fields(i).Name + "</b></td>")document.write("</tr>")// 显示数据库内容while (!objrs.EOF){document.write("<tr>")// 显示每笔记录的区域<script language= javascript runat= server > //用 JavaScript 写服务器端连接数据库的代码示例 var conn = new ActiveXObject( ADODB Connection ) conn Open( Provider=SQLOLEDB Data Source=localhostUser ID=sa + Password=passwordInitial Catalog=meizz )
var rs = new ActiveXObject( ADODB Recordset ) var sql= select user_kind from tbRightSet where user_id= + Account +
lishixinzhi/Article/program/Java/JSP/201311/19562
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)