我有一个字符串列表,我需要检查列表中的任何值是否包含在数据库表中。如果存在则返回现有值的数据集。
public DataSet CheckDocumentNumber(List<string> DocNumber)
{
DataSet DocNum = new DataSet();
SqlTransaction transaction = DALDBConnection.SqlConnection.BeginTransaction();
try
{
string[] taleNames = new string[1];
taleNames[0] = "DocNum";
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@DocNumber", DocNumber);
SqlHelper.FillDataset(transaction, CommandType.StoredProcedure, "spCheckDocNumber", DocNum, taleNames, param);
transaction.Commit();
}
catch (Exception e)
{
transaction.Rollback();
}
return DocNum;
}
我的存储过程是
CREATE PROCEDURE spCheckDocNumber
@DocNumber VARCHAR(MAX)
AS
BEGIN
SELECT * FROM tblDocumentHeader WHERE DocumentNumber = @DocNumber
END
我需要知道如何将列表传递给存储过程以及如何在过程中检查列表。请帮助