问题描述
我想知道是否有人知道从Node.js连接到Microsoft SQL数据库的方法.我知道MySQL驱动程序,但是我有一些数据需要从MS SQL数据库中提取,并且宁愿直接从Node.js中提取,也不想破解某种形式的PHP脚本.
I was wondering if anyone was aware of a way to connect to a Microsoft SQL database from Node.js. I'm aware of the MySQL drivers, but I have data that I need to pull from a MS SQL database and would rather pull directly from Node.js rather than hack a PHP script of some sort in place.
推荐答案
我怀疑您必须使用JSON输出Web服务包装SQL Server.从积极的方面来说,这应该相对容易些.
I suspect you'll have to wrap your SQL Server with a JSON outputting web-service. On the positive side, it should be relatively easy to do.
如果node.js中的JavaScript引擎可以做到这一点,那就很好:(来自):
Be nice if the JavaScript engine in node.js could do this: (from How to connect to SQL Server database from JavaScript in the browser?):
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;
这篇关于从Node.js连接到远程Microsoft SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!