Introcution: Here you can call and execute stored procedure from code behind and pass the parameters and fill dataset.
Implementation:
DataSet ds = new DataSet();
DataTable dt;
sb.Append("<table>");
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("sp_DistwiseDetails1", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@RetriveType", SqlDbType.VarChar).Value = 2;
command.Parameters.Add("@FromDate", SqlDbType.VarChar).Value = DateTime.Now.AddYears(-2);
command.Parameters.Add("@ToDate", SqlDbType.VarChar).Value = DateTime.Now.ToShortDateString();
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(ds);
}
}
}
dt = ds.Tables[0];
}
catch
{
}
Implementation:
DataSet ds = new DataSet();
DataTable dt;
sb.Append("<table>");
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("sp_DistwiseDetails1", connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@RetriveType", SqlDbType.VarChar).Value = 2;
command.Parameters.Add("@FromDate", SqlDbType.VarChar).Value = DateTime.Now.AddYears(-2);
command.Parameters.Add("@ToDate", SqlDbType.VarChar).Value = DateTime.Now.ToShortDateString();
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(ds);
}
}
}
dt = ds.Tables[0];
}
catch
{
}
No comments:
Post a Comment