Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void DataSet1Button_Click(object sender, EventArgs e)
- {
- this.ReportViewer1.Reset();
- this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
- this.ReportViewer1.LocalReport.DataSources.Clear();
- DataTable dt1 = getDataSet1Data();
- ReportDataSource datasource = new ReportDataSource("DataSet1", dt1);
- this.ReportViewer1.LocalReport.DataSources.Add(datasource);
- this.ReportViewer1.LocalReport.ReportPath = (@"...mypath...MyApp7Report1.rdlc");
- this.ReportViewer1.LocalReport.Refresh();
- this.ReportViewer1.Visible = true;
- }
- protected void DataSet2Button_Click(object sender, EventArgs e)
- {
- this.ReportViewer1.Reset();
- this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
- this.ReportViewer1.LocalReport.DataSources.Clear();
- DataTable dt2 = getDataSet2Data();
- ReportDataSource datasource2 = new ReportDataSource("DataSet2", dt2);
- this.ReportViewer1.LocalReport.DataSources.Add(datasource2);
- this.ReportViewer1.LocalReport.ReportPath = (@"...mypath...MyApp7Report2.rdlc");
- this.ReportViewer1.LocalReport.Refresh();
- this.ReportViewer1.Visible = true;
- }
- public DataTable getDataSet1Data()
- {
- string constring = "Data Source = x.x.x.x; Initial Catalog = Adventureworks2014; Integrated Security = SSPI";
- using (SqlConnection sqlconn = new SqlConnection(constring))
- {
- string commandText = "SELECT ProductID, Name, ProductNumber, MakeFlag, FinishedGoodsFlag, Color, SafetyStockLevel, ReorderPoint, StandardCost, ListPrice, Size, SizeUnitMeasureCode, WeightUnitMeasureCode, Weight, DaysToManufacture, ProductLine, Class, Style, ProductSubcategoryID, ProductModelID, SellStartDate, SellEndDate, DiscontinuedDate, rowguid, ModifiedDate FROM Production.Product";
- using (SqlCommand sqlcomm = new SqlCommand(commandText, sqlconn))
- {
- using (SqlDataAdapter sqladap = new SqlDataAdapter(sqlcomm))
- {
- using (DataSet1 dset1 = new DataSet1())
- {
- sqladap.Fill(dset1, dset1.Product.TableName);
- return dset1.Product;
- }
- }
- }
- }
- }
- public DataTable getDataSet2Data()
- {
- string constring = "Data Source = x.x.x.x; Initial Catalog = Adventureworks2014; Integrated Security = SSPI";
- using (SqlConnection sqlconn = new SqlConnection(constring))
- {
- string commandText = "SELECT PurchaseOrderID, PurchaseOrderDetailID, OrderQty, ProductID, ReceivedQty, RejectedQty, StockedQty FROM Purchasing.PurchaseOrderDetail";
- using (SqlCommand sqlcomm = new SqlCommand(commandText, sqlconn))
- {
- using (SqlDataAdapter sqladap = new SqlDataAdapter(sqlcomm))
- {
- using (DataSet2 dset2 = new DataSet2())
- {
- sqladap.Fill(dset2, dset2.PurchaseOrderDetail.TableName);
- return dset2.PurchaseOrderDetail;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement