Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点MSSQL查询事务_Javascript_Sql Server_Node.js_Coffeescript - Fatal编程技术网

Javascript 节点MSSQL查询事务

Javascript 节点MSSQL查询事务,javascript,sql-server,node.js,coffeescript,Javascript,Sql Server,Node.js,Coffeescript,使用节点MsSQL库成功完成数据库事务时遇到问题。一切似乎都在执行,但是,我的数据库没有收到任何数据。非常感谢您的帮助,谢谢 # Create connection config = user: '' password: '' server: '' database: '' connection = new sql.Connection(config) # Send to table sendData = (a, b, dsHost, dsUserna

使用节点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()可以根据情况调用一次或一千次

request = new sql.Request(transaction)
request.query "INSERT INTO dbo.sessionManager SET host=?, ...], (err, recordset) ->
   // I think that your query is incorrect, e.g. by db constraints.
   // So you need check err here.
   transaction.commit (err, recordset) ->
       if err
          throw err