public override global::System.Data.DataSet Clone() { SampleDBDataSet cln = ((SampleDBDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { SampleDBDataSet ds = new SampleDBDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportGenerator(); ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report/Report1.rdlc"); SampleDBDataSet dsCustomers = GetData("select top 20 * from employee"); ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } }
private void ReportGenerator() { Warning[] warnings; string[] streamIds; string mimeType = string.Empty; string encoding = string.Empty;//enter code here` string extension = string.Empty; // DataSet dsGrpSum, dsActPlan, dsProfitDetails, // dsProfitSum, dsSumHeader, dsDetailsHeader, dsBudCom = null; //enter code here //This is optional if you have parameter then you can add parameters as much as you want ReportParameter[] param = new ReportParameter[5]; param[0] = new ReportParameter("Report_Parameter_0", "1st Para", true); param[1] = new ReportParameter("Report_Parameter_1", "2nd Para", true); param[2] = new ReportParameter("Report_Parameter_2", "3rd Para", true); param[3] = new ReportParameter("Report_Parameter_3", "4th Para", true); param[4] = new ReportParameter("Report_Parameter_4", "5th Para"); // DataSet dsData = "Fill this dataset with your data"; //ReportDataSource rdsAct = new ReportDataSource("RptActDataSet_usp_GroupAccntDetails", dsActPlan.Tables[0]); SampleDBDataSet dsCustomers = GetData("select top 20 * from employee"); ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[0]); ReportViewer viewer = new ReportViewer(); viewer.LocalReport.Refresh(); viewer.LocalReport.ReportPath = Server.MapPath("~/Report/Report1.rdlc"); //"Reports/AcctPlan.rdlc"; //This is your rdlc name. // viewer.LocalReport.SetParameters(param); viewer.LocalReport.DataSources.Add(datasource); // Add datasource here byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings); // byte[] bytes = viewer.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamIds, out warnings); // Now that you have all the bytes representing the PDF report, buffer it and send it to the client. // System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename= filename" + "." + extension); Response.OutputStream.Write(bytes, 0, bytes.Length); // create the file Response.Flush(); // send it to the client to download Response.End(); }
private SampleDBDataSet GetData(string query) { string conString = ConfigurationManager.ConnectionStrings["SampleDBConnectionString"].ConnectionString; SqlCommand cmd = new SqlCommand(query); using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (SampleDBDataSet dsCustomers = new SampleDBDataSet()) { sda.Fill(dsCustomers, "Employee"); return(dsCustomers); } } } }