2

我需要你的双手。

我在 c#.net 中有 2 个 Windows 窗体,其中第一个窗体包含选中的列表框,从该框中收集 id,将值传递给我编写了这样的存储过程的第二个窗体

ALTER PROCEDURE [dbo].[sp_GDE_QA]
@oks_ids varchar(100),
@Operation varchar(50) 
AS BEGIN
    declare @Execute as varchar(100)

    set @Execute = 'select oks_id, path from tb_gde_qc where status=''QC Completed'' and oks_id in '''+@oks_ids+'''';

exec(@Execute) 
END

现在我想传递参数的值@oks_ids。例如

select oks_id, path 
from tb_gde_qc 
where status=''QC Completed'' 
  and oks_id in ('GD_01358', 'GD_01361', 'GD_01363')

谁能帮我?会感谢所有人

4

1 回答 1

0

尝试这个

ALTER PROCEDURE [dbo].[sp_GDE_QA]
@oks_ids varchar(100),
@Operation varchar(50) 
AS BEGIN
    declare @Execute as varchar(100)

    set @Execute = 'select oks_id, path from tb_gde_qc where status=''QC Completed'' and oks_id in '''+@oks_ids+'''';

sp_ExecuteSQL @Execute 
END

sp_ExecuteSQL 应该能够处理参数内字符串的传递。

我能问一下@Operation 在哪里发挥作用吗?

于 2012-12-14T17:04:33.720 回答