1
我在使用節點MsSQL庫https://www.npmjs.com/package/mssql成功完成事務到我的數據庫時遇到問題。一切似乎都在執行,但是,我沒有收到任何數據給我的數據庫。任何幫助非常感謝,謝謝!節點MSSQL查詢事務
# Create connection
config =
user: ''
password: ''
server: ''
database: ''
connection = new sql.Connection(config)
# Send to table
sendData = (a, b, dsHost, dsUsername, dsSessionname, dsMode, dsRemotelocation, dsSessionactivity, dsActivityduration) ->
transaction = new sql.Transaction(connection)
transaction.begin (err) ->
if err
console.log err
else
request = new sql.Request(transaction)
request.query "INSERT INTO dbo.sessionManager SET host=?, username=?, sessionname=?, mode=?, remotelocation=?, sessionactivity=?, activityduration=?", [dsHost, dsUsername, dsSessionname, dsMode, dsRemotelocation, dsSessionactivity, dsActivityduration], (err, recordset) ->
transaction.commit (err, recordset) ->
if err
throw err
sendData()可以調用一次或一千次取決於具體情況。