我无法解决使用选择记录的问题WHERE IN ().我正在C#后端工作,我发送一个逗号分隔的id值字符串.我期待查询该字符串中的所有记录.
这是我的示例字符串:
"548,549,550,551,712,713"
Run Code Online (Sandbox Code Playgroud)
这是我的 SQL Stored Procedure
@ids nvarchar(200)
SELECT * FROM Users
WHERE USers.ID IN (@ids)
Run Code Online (Sandbox Code Playgroud)
但是我收到一个错误:
将nvarchar值'548,549,550,551,712,713'转换为数据类型int时转换失败.
谢谢
我做了一些研究,但很少有类似的问题,但没有解决我的问题.
我在报告中对记录进行Ajax调用,我通过Ajax设置/删除标志.
jQuery的
jQuery('.flag').click(function(){
if(jQuery(this).hasClass('active_flag')){
// REMOVE Record
jQuery.ajax({
url: '/flag/remove',
type: "post",
data: { '_method' : 'delete',
'timeRecordID':jQuery(this).attr('data-record'),
'_token': '{!! csrf_token() !!}'
},
success: function(data){
jQuery(this).removeClass('active_flag'); // (this) doesn't refer to same (this) inside the click function
}
});
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个链接StackOverflow的解决方案,但这并没有解决我的问题.
感谢帮助