我正在处理存储过程如果存在日期然后获取记录其他最近90天数据过程工作正常但如果我通过代码发送输入,我得到一个传入的表格数据流(TDS)远程过程调用(RPC )协议流不正确。
这是我的程序。
USE [support_db_dev]
GO
/****** Object: StoredProcedure [dbo].[get_audit_list_for_sites_list_enh] Script Date: 5/7/2017 2:55:24 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[get_audit_list_for_sites_list_enh]
(
@site_list varchar(MAX)
,@ip_audit_dttm_from datetime = null
,@ip_audit_dttm_to datetime = null
)
/**************************************************************************************************
* Name : get_accepted_terms_da_user
*
* Description : This Procedure is to get the user activity, user, admin etc details for auditing
*
* Author : Sandeep (rajsa06)
*
* Date Written : 11th Jan 2017
*
***************************************************************************************************
* Called By
* None.
*
* Objects S I U D E
* dbo.user_info X
* dbo.user_audit X
*
* Called Objects
* None.
**************************************************************************************************/
AS
BEGIN
if(@ip_audit_dttm_from IS NULL AND @ip_audit_dttm_to IS NULL )
BEGIN
DECLARE @t_sites TABLE
(site_id INTEGER NOT NULL PRIMARY KEY)
INSERT
INTO @t_sites
(site_id)
SELECT integer_id
FROM dbo.dba_tfn_split_commaseparated_int_string(@site_list)
SELECT a.site_id AS siteId
,a.activity AS activity
,a.activity_desc AS activityDesc
,a.audit_dttm AS auditDate
,b.first_name AS userFirstName
,b.last_name AS userLastName
,b.login_name AS userEmail
,CONCAT(c.first_name,' ', c.last_name) AS adminName
FROM (SELECT * FROM dbo.user_audit WHERE site_id IN (SELECT site_id FROM @t_sites) AND audit_dttm >= DATEADD(day, -90, GETDATE())) a
INNER JOIN dbo.user_info b
ON a.user_id = b.user_id
INNER JOIN dbo.user_info c
ON a.da_user_id = c.user_id ORDER BY auditDate DESC
END
ELSE
BEGIN
INSERT
INTO @t_sites
(site_id)
SELECT integer_id
FROM dbo.dba_tfn_split_commaseparated_int_string(@site_list)
SELECT a.site_id AS siteId
,a.activity AS activity
,a.activity_desc AS activityDesc
,a.audit_dttm AS auditDate
,b.first_name AS userFirstName
,b.last_name AS userLastName
,b.login_name AS userEmail
,CONCAT(c.first_name,' ', c.last_name) AS adminName
FROM (SELECT * FROM dbo.user_audit WHERE site_id IN (SELECT site_id FROM @t_sites) AND audit_dttm >= @ip_audit_dttm_from AND audit_dttm <= @ip_audit_dttm_to) a
INNER JOIN dbo.user_info b
ON a.user_id = b.user_id
INNER JOIN dbo.user_info c
ON a.da_user_id = c.user_id ORDER BY auditDate DESC
END
END
这是我的Noode.js代码。
new MsSqlWrapper()
.runStoreProc({
storeProcName:
constants.storedProcs.get_audit_list_for_sites_list_enh,
inputs: [
{
name: 'site_list',
value: siteIdList.data.details
},
{
name: 'ip_audit_dttm_from',
value: fromDate
},
{
name: 'ip_audit_dttm_to',
value: toDate
}
]
})
我的输入:
"input": {
"userId": "336931",
"connectSiteId": "999999",
"fromDate": "2009-10-21 08:20:39.477",
"toDate": "2009-12-21 08:20:39.477"
}
答案 0 :(得分:0)
我有与此相同的错误消息,因为我已更改了使用SQL“文本”而不是“存储过程”的调用,因此错误的CommandType是可能导致此错误的另一件事。
SqlCommand cmd = new SqlCommand(query, connection);
cmd.CommandType = CommandType.Text;