2015-12-18 18 views
0

参数我不知道如何格式化字符串请求边缘SQL为了执行需要参数的存储过程。如果我更改存储过程不使用参数,只需发送exec sp_III_UpdateOperMgr它正确执行。想不通的语法调用存储过程与边缘SQL

下面是我使用的边缘-SQL,返回错误

语法“找不到存储的过程sp_III_UpdateOperMgr @ quoteNumber,@采购单号码'。”

var updateOpMgrSql = edge.func('sql',{ 
    connectionString: GM_CONNECTION_STRING, 
    source:function() { 
     /* 
     exec sp_III_UpdateOperMgr @quoteNumber,@poNumber 
     */ 
    }, 
}); 

下面是MS SQL Server Management Studio中使用的语法正确执行 exec sp_III_UpdateOperMgr @quoteNumber='121715JM-1',@innovationJobNumber='999999'

回答

0

假设在存储过程的参数本身是@quoteNumber和@poNumber你可以尝试:

var updateOpMgrSql = edge.func('sql',{ 
connectionString: GM_CONNECTION_STRING, 
source:function() { 
    /* 
    exec sp_III_UpdateOperMgr @[email protected],@[email protected] 
    */ 
}, 
}); 

然后调用updateOpMgrSql函数:

updateOpMgrSql({ quoteNumberParam: 10, poNumberParam: 15 }, function (error, result) { 
    if (error) throw error; 
    console.log(result); 
}); 
+0

看起来像它是在2013年添加在[这里](https://github.com/tjanczuk/edge-sql/commit/1ddb418a77e391673a5e3d97ee7769a2fba3e73e)。如果它不需要参数,该过程也适用。 –

+0

所以你怎么打电话updateOpMgrSql?像'updateOpMgrSql({quoteNumber:10,采购单号码:15}?...' – strickt01

+0

我已经编辑我的答案,你的链接... – strickt01

0

不得不对SP名称后的第一空空间加分,我不知道这是否有更好的方式,但我最终编辑升C代码中使用了由JavaScript.I然后坐数组中的第一项将是过程的实际名称。

以前是包括所有需要的SP名称时传递的参数只有 commandString.Substring(5).TrimEnd()

后,我通过在第一白空间 commandString.Substring(5).Split(' ')[0].TrimEnd()

async Task<object> ExecuteStoredProcedure( string connectionString, string commandString, IDictionary<string, object> parameters) { using (SqlConnection connection = new SqlConnection(connectionString)) { var spName = commandString.Substring(5).Split(' ')[0].TrimEnd(); SqlCommand command = new SqlCommand(spName, connection) { CommandType = CommandType.StoredProcedure }; using (command) { return await this.ExecuteQuery(parameters, command, connection); } } } 分割字符串得到数组中的第一项