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 设置为 ENVIROMENT_VARIALBE 感到不舒服!
set EDGE_SQL_CONNECTION_STRING=Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True
但我找不到其他方法来做到这一点!即使在GitHub https://github.com/tjanczuk/edge#how-to-script-t-sql-in-a-nodejs-application我找不到另一种设置 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);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)