Sunday, 1 January 2012

Use IN sql query Stored Procedure & retrieve data


ALTER PROCEDURE dbo.StoredProcedure2

@userid varchar(500)

AS
BEGIN
SET NOCOUNT ON

DECLARE @SQL varchar(600)

SET @SQL =
'SELECT  USER_NAME, FIRST_NAME, PASSWORD, LAST_NAME, MIDDLE_NAME, SRNO FROM  USER_MAS
WHERE SRNO IN (' + @userid + ')'

EXEC(@SQL)
END


 protected void BtnSpIn_Click(object sender, EventArgs e)
    {
        SqlDB objDB = new SqlDB();
        objDB.Prepare("StoredProcedure2", CType.StoredProcedure);
        objDB.AddCmdParameter("@userid", DType.Varchar,"1,2", ParaDirection.In, false);
        DataTable objDT = new DataTable();
        objDT = objDB.ExecuteCommandDataReturn(); 
    }

No comments:

Post a Comment