如何将数据从SQL Server绑定到HTML页面。 [英] How do I bind data from SQL Server to an HTML page.?

查看:229
本文介绍了如何将数据从SQL Server绑定到HTML页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用javascript,AJAX,jquery将sql server中的数据绑定/显示到.html页面,但不使用c#,php,vb.net等....任何人都可以通过发布一些参考链接来帮助通过发布代码本身..

I want to bind/show data from sql server into a .html page by using javascript,AJAX,jquery but without using c#,php,vb.net etc.... can anyone plz help by posting some reference links or by posting the code itself..

推荐答案

有一种方法可以做到这一点,但由于安全问题,实际上不建议这个代码只适用于IE浏览器。我的问题实际上是你为什么需要这个。无论如何,html页面都托管在Web服务器上,因此您应该可以使用服务器端脚本语言。





There is a way of doing it but it is really not recommended due to security issues also this code will only work on IE browsers. My question to you is actually why do you need this. The html page is hosted on a webserver anyway so a serverside scripting language should be available to you.


var connection = new ActiveXObject("ADODB.Connection") ;

var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";

connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
   document.write(rs.fields(1));
   rs.movenext;
}

rs.close;
connection.close;


这篇关于如何将数据从SQL Server绑定到HTML页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆