Programmatically??
I want to bind it with gridview
i am using like this
Collapse | Copy CodesqldsSiteList.SelectCommandType = SqlDataSourceCommandType.StoredProcedure sqldsSiteList.SelectCommand = "Stp_RmsAdmin_GetsitesBycustomization"
Collapse | Copy CodesqldsSiteList.SelectParameters.Add("@CustomerID", TypeCode.Int32, ddlCustomer.SelectedValue) sqldsSiteList.SelectParameters(0).Direction = ParameterDirection.Input
Collapse | Copy CodesqldsSiteList.SelectParameters.Add("@PageIndex", TypeCode.Int32, "1") sqldsSiteList.SelectParameters(1).Direction = ParameterDirection.Input GridView1.DataBind()
when i bind it to grid it gives me error
Collapse | Copy Code"Procedure or Function 'Stp_RmsAdmin_GetsitesBycustomization' expects parameter '@CustomerID', which was not supplied."

Pravin MoreRank #1,419 · 1.2K reputationPosted Dec 7, 2011, 6:54 PM EST
Hi Mohamad, use bolow code to call stored procedure...........
SqlConnection spcon =new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["commonconnection"].ToString());
spcon.Open();
SqlDataReader dr;
SqlCommand spcmd;
spcmd = new SqlCommand("Stp_RmsAdmin_GetsitesBycustomization", spcon);
spcmd.Parameters.Add(new SqlParameter(""@CustomerID", ddlCustomer.SelectedValue));
spcmd.Parameters.Add(new SqlParameter(""@PageIndex", "1"));
spcmd.CommandType = CommandType.StoredProcedure;
dr = spcmd.ExecuteReader();
Thanks,
Pravin.
mohammad qasimRank #3,405 · 424 reputationPosted Dec 7, 2011, 9:54 PM EST
my mistake was this
just remove "@" from paramter
its working
though i declared paramter in procedure like "@CustomerID"
but we need to add parameter name without "@"
happy programing