Sql server edge-sql.js如何设置connectionString?
这段代码运行得很好,但我对将ConnectionString设置为Environment\u VARIALBE感到不舒服Sql server edge-sql.js如何设置connectionString?,sql-server,node.js,Sql Server,Node.js,这段代码运行得很好,但我对将ConnectionString设置为Environment\u VARIALBE感到不舒服 var edge = require('edge'); var getProduct = edge.func('sql', function () {/* select * from Products where ProductId = @myProductId */}); getProduct({ myProductId: 10 }, function
var edge = require('edge');
var getProduct = edge.func('sql', function () {/*
select * from Products
where ProductId = @myProductId
*/});
getProduct({ myProductId: 10 }, function (error, result) {
if (error) throw error;
console.log(result);
});
但是我找不到一个不同的方法来做到这一点!即使在网络上,我也找不到其他方法来设置ConnectionString!因此,我想知道在OOB edge-sql.js中是否有可能在代码中设置ConnectionString?在查看了edge sql的源代码后,我能够了解它是如何工作的,我想知道为什么在GitHub上会使用环境变量来描述它 无论如何,下面是在node.js中设置ConnectionString的代码:-) 显然(),您也可以内联执行:
var edge = require('edge');
var params = {
connectionString: "Data Source=localhost;Initial Catalog=ITSM_604;Integrated Security=True",
source: "select top 1 last_name from account_contact"
};
var getContacts = edge.func('sql', params);
getContacts(null, function(error, result){
if (error) throw error;
console.log(result);
});
我也不喜欢环境变量技术 好的,伙计们。您想使用集成安全性连接到SQL Server(在我的例子中是2005)?使用connectionString:“Data source=;Integrated security=true”替换为sql server的主机在我的情况下,它是网络上的某台pc。
var edge = require('edge');
var params = {
connectionString: "Data Source=localhost;Initial Catalog=ITSM_604;Integrated Security=True",
source: "select top 1 last_name from account_contact"
};
var getContacts = edge.func('sql', params);
getContacts(null, function(error, result){
if (error) throw error;
console.log(result);
});
var mySelect = edge.func('sql', {
source: function () {/*
select * from Product
*/},
connectionString: 'your connection string goes here'
});