***************crystal report by date**************
data table
*********************
public DataTable retrivedata(string val)
{
SqlConnection con = new SqlConnection(path);
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
try
{
con.Open();
//Stored procedure calling. It is already in sample db.
cmd.CommandText = "sp_slectDatabyDate";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ActivationDate", val);
cmd.Connection = con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Sheet1");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
if (con.State != ConnectionState.Closed)
con.Close();
}
return ds.Tables[0];
}
**************form button behind coe*************
CrystalReport2 crp = new CrystalReport2();
crp.SetDataSource(new MyProc().retrivedata(val));
CrystalReportViewer1.ReportSource = crp;
data table
*********************
public DataTable retrivedata(string val)
{
SqlConnection con = new SqlConnection(path);
SqlCommand cmd = new SqlCommand();
DataSet ds = null;
SqlDataAdapter adapter;
try
{
con.Open();
//Stored procedure calling. It is already in sample db.
cmd.CommandText = "sp_slectDatabyDate";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ActivationDate", val);
cmd.Connection = con;
ds = new DataSet();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds, "Sheet1");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
cmd.Dispose();
if (con.State != ConnectionState.Closed)
con.Close();
}
return ds.Tables[0];
}
**************form button behind coe*************
CrystalReport2 crp = new CrystalReport2();
crp.SetDataSource(new MyProc().retrivedata(val));
CrystalReportViewer1.ReportSource = crp;
No comments:
Post a Comment