Sunday, February 1, 2009

Crystal Report Problem

protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("sp_repairid", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Add("@Repairid", SqlDbType.Int).Value = TextBox1.Text;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds, "tbrepair1");
//int tes = ds.Tables[0].Rows.Count;
ReportDocument report = new ReportDocument();
report.FileName = Server.MapPath("crystalreport2.rpt");
report.SetDataSource(ds);
//report.PrintOptions.PrinterName=
//report.PrintToPrinter(1,false,0,0);
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.DataBind();
cmd.Dispose();
}

No comments:

Post a Comment