1
Answer

the web method is not returning any data when used

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)
1
Vignesh Mani

Vignesh Mani

NA 13.4k 937.6k 9y
DateTime startTime = varValue  DateTime endTime = varTime  TimeSpan span = endTime.Subtract ( startTime ); Console.WriteLine( "Time Difference (seconds): " + span.Seconds ); Console.WriteLine( "Time Difference (minutes): " + span.Minutes ); Console.WriteLine( "Time Difference (hours): " + span.Hours ); Console.WriteLine( "Time Difference (days): " + span.Days );
0
Rajeev Punhani

Rajeev Punhani

NA 4.7k 402.4k 9y
 
DateTime start_time = Convert.ToDateTime("2014-12-04 08:10:32");
DateTime end_time = Convert.ToDateTime("2014-12-04 12:34:45");
TimeSpan t = end_time - start_time;
//Here t will be the time difference in format HH:MM:ss .So output will be 04:24:13
Response.Write(t);
//For getting in format what you expected just format timespan
var res = String.Format("{0}.{1}",t.Hours,t.Minutes);
Response.Write("<br/>"+ res);
0
Upendra Pratap Shahi

Upendra Pratap Shahi

NA 13.3k 861.3k 9y
TimeSpan time1 = TimeSpan.Parse(textBox1.Text);
TimeSpan time2 = TimeSpan.Parse(textBox2.Text);
TimeSpan difference = time1 - time2;
int hours = difference.Hours;
int minutes = difference.Minutes;
or
var first = new DateTime(2012, 05, 08, 10, 30, 00);
var second = new DateTime(2012, 05, 08, 11, 49, 13);
var diff = first - second;
var hours = diff.Hours;
var mins = diff.Minutes;
0
Vignesh Mani

Vignesh Mani

NA 13.4k 937.6k 9y

string sDateFrom = "11:56:00";
string sDateTo = "12:12:00";
if (DateTime.TryParse(sDateFrom, out dFrom) && DateTime.TryParse(sDateTo, out dTo))
{
TimeSpan TS = dTo - dFrom;
int hour = TS.Hours;
int mins = TS.Minutes;
int secs = TS.Seconds;
string timeDiff = hour.ToString("00") + ":" + mins.ToString("00") + ":" + secs.ToString("00");
Response.Write(timeDiff); //output 16 mins in format 00:16:00
}