如何从javascript连接到SQL Server数据库? [英] How to connect to SQL server database from javascript?
本文介绍了如何从javascript连接到SQL Server数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i在javascript中创建数据库连接有问题。
如果你知道创建数据库连接,请分享信息。
提前谢谢。
i have problem with creating the database connection in javascript.
if u know the creating the database connection,please share the information.
Thanks in advance.
推荐答案
看看这里。它不推荐,它不适用于IE以外的任何其他任何东西,这是非常糟糕的做法,
http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from- javascript [ ^ ]
而不是这样做,你应该从服务器端代码(.Net,Java,PHP等)建立数据库连接)。
Have a look here. It's not recommended, it won't work on anything other than IE and it's extremely bad practice,
http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript[^]
Instead of doing this, you should be making your database connections from server-side code (.Net, Java, PHP etc).
试试这个我的朋友,
Try this one my friend,
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;
问候,
Eduard
Regards,
Eduard
这篇关于如何从javascript连接到SQL Server数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文