I have a string list and i need to check if any of the values in the list contains in the database table.if exists return the data set of existing values.
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;
}
My stored procedure is
CREATE PROCEDURE spCheckDocNumber
@DocNumber VARCHAR(MAX)
AS
BEGIN
SELECT * FROM tblDocumentHeader WHERE DocumentNumber = @DocNumber
END
I need to know that how do I have to pass the list to the stored procedure and how to check the list with in the procedure. plz help