Aniruddh Kewat

Aniruddh Kewat

  • NA
  • 30
  • 20.7k

the web method is not returning any data when used

Jul 10 2015 5:49 PM

i m using the below web method to return data when page scrolls and is working good.....but when i m using the same web method in different web service to see the data returned,

it is not showing the desired data....this is my web method.....

thanks in advance....
 
[WebMethod] public DataSet GetCustomers(int pageindex, int categoryid, string brand, int price)
   { return GetCustomersData(pageindex, categoryid, brand, price);
   }
public DataSet GetCustomersData(int pageindex, int categoryId, string brands, int price)
{
   string query = "Getproducts";
   SqlCommand cmd = new SqlCommand(query);
   cmd.CommandType = CommandType.StoredProcedure;
   cmd.Parameters.AddWithValue("@PageIndex", pageindex);//1
   cmd.Parameters.AddWithValue("@PageSize", 12);//2
   cmd.Parameters.AddWithValue("@CategoryId", categoryId);//3
   cmd.Parameters.AddWithValue("@Brands", brands);//4
   cmd.Parameters.AddWithValue("@Price", price);//5
   cmd.Parameters.Add("@PageCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
   return GetData(cmd);
}
 
public DataSet GetData(SqlCommand cmd)
{
   string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
   using (SqlConnection con = new SqlConnection(CS))
   {
      using (SqlDataAdapter sda = new SqlDataAdapter())
      {
         cmd.Connection = con;
         sda.SelectCommand = cmd;
         using (DataSet ds = new DataSet())
            {
               sda.Fill(ds, "Customers");
               DataTable dt = new DataTable("PageCount");
               dt.Columns.Add("PageCount");
               dt.Rows.Add();
               dt.Rows[0][0] = cmd.Parameters["@PageCount"].Value;
               ds.Tables.Add(dt);
               return ds;
            }
      }
   }
}
 

Answers (1)