Wednesday, 6 July 2011

how to pass session parameters through storeprocedure and how to apply multiple if else condition


 


ALTER procedure [dbo].[PMP_GetGrantDonation_Type_byGD_Type_Id] 2 ,'Employee'@GD_Type_Id int ,@Role AS VARCHAR(200)as IF (UPPER(@Role) = UPPER('Employees') OR UPPER(@Role) = UPPER('Employee')) Begin
if
(@GD_Type_Id = 1)Begin
select
* from PMP_GrantDonation_Typewhere gd_type_id=@GD_Type_Id and SubType_Name NOt In ( 'In Kind Donation')order
end
else
Begin
select
by GD_SubType_id asc * from PMP_GrantDonation_Typewhere gd_type_id=@GD_Type_Id and SubType_Name NOt In ( 'In-kind Mission','In-kind Friends & Need','In-kind')order
end
end
else
by GD_SubType_id asc if (UPPER(@Role) = UPPER('Vendors') OR UPPER(@Role) = UPPER('Vendor')) Begin
if
(@GD_Type_Id = 1)Begin
select
* from PMP_GrantDonation_Typewhere gd_type_id=@GD_Type_Id and SubType_Name NOt In ( 'In Kind Donation')order
end
else
Begin
select
by GD_SubType_id asc * from PMP_GrantDonation_Typewhere gd_type_id=@GD_Type_Id and SubType_Name In ('In-kind')order
end
end
by GD_SubType_id asc
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "PMP_GetGrantDonation_Type_byGD_Type_Id";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = sqlconn;
cmd.Parameters.Add("@GD_Type_Id", GD_Type_Id);
//BSP2 11131
cmd.Parameters.Add("@Role", SqlDbType.VarChar, 200);
cmd.Parameters["@Role"].Value = HttpContext.Current.Session["Description"].ToString();
//BSP2 11131
SqlDataAdapter sqlda = new SqlDataAdapter();
sqlda.SelectCommand = cmd;
sqlda.Fill(ds);

No comments:

Post a Comment