Click here to Skip to main content
15,921,989 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one tell actully wht is missing ,becoz it not give record empty set is return
C#
String strConnString = ConfigurationManager.ConnectionStrings["con"].ConnectionString;

           SqlConnection con = new SqlConnection(strConnString);

           try
           {

           SqlCommand cmd = new SqlCommand();
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.AddWithValue("@Flag", 112);
           cmd.Parameters.AddWithValue("@Para1",SqlDbType.NVarChar).Value=secnm;
           cmd.CommandText = "spSelect";
           cmd.Connection = con;

            // Filling Data to Gridviewsearch in View3

                   con.Open();
                   SqlDataAdapter da = new SqlDataAdapter(cmd);
                   DataSet ds = new DataSet();
                   da.Fill(ds);


spSelect Store Procedure:

SQL
ELSE IF @Flag=112 
BEGIN
SELECT     Team.tcode, Team.tnm, Section1.sdesc
FROM         Team INNER JOIN
                      Section1 ON Team.sec_id = Section1.sec_id
WHERE     (Section1.sdesc = @Para1)
END
Posted
Updated 12-Oct-15 21:34pm
v3
Comments
Member 12003400 13-Oct-15 1:35am    
Put a breakpoints and check,,also check parameter values,
ASPDevloper 13-Oct-15 1:39am    
i also check it para value ,value assign or proper run but empty set is return or when this Qury put in Sqladapter then it will run and give results but when in Store procedur call then not give result

Change
SQL
cmd.Parameters.AddWithValue("@Para1",SqlDbType.NVarChar).Value=secnm;


to

cmd.Parameters.Add("@Para1",SqlDbType.NVarChar,-1).Value=secnm;
 
Share this answer
 
v2
Comments
ASPDevloper 13-Oct-15 4:41am    
i will try this form but not work ....
Hi

Please try this

cmd.Parameters.Add("@Para1",SqlDbType.NVarChar,500).Value=secnm;

@500 = length of character
 
Share this answer
 
Comments
ASPDevloper 13-Oct-15 5:28am    
thnkx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900