Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. protected void DataSet1Button_Click(object sender, EventArgs e)
  2. {
  3. this.ReportViewer1.Reset();
  4. this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
  5. this.ReportViewer1.LocalReport.DataSources.Clear();
  6.  
  7. DataTable dt1 = getDataSet1Data();
  8. ReportDataSource datasource = new ReportDataSource("DataSet1", dt1);
  9. this.ReportViewer1.LocalReport.DataSources.Add(datasource);
  10. this.ReportViewer1.LocalReport.ReportPath = (@"...mypath...MyApp7Report1.rdlc");
  11.  
  12. this.ReportViewer1.LocalReport.Refresh();
  13. this.ReportViewer1.Visible = true;
  14.  
  15. }
  16.  
  17. protected void DataSet2Button_Click(object sender, EventArgs e)
  18. {
  19. this.ReportViewer1.Reset();
  20. this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
  21. this.ReportViewer1.LocalReport.DataSources.Clear();
  22.  
  23. DataTable dt2 = getDataSet2Data();
  24. ReportDataSource datasource2 = new ReportDataSource("DataSet2", dt2);
  25. this.ReportViewer1.LocalReport.DataSources.Add(datasource2);
  26. this.ReportViewer1.LocalReport.ReportPath = (@"...mypath...MyApp7Report2.rdlc");
  27.  
  28. this.ReportViewer1.LocalReport.Refresh();
  29. this.ReportViewer1.Visible = true;
  30.  
  31. }
  32.  
  33. public DataTable getDataSet1Data()
  34. {
  35. string constring = "Data Source = x.x.x.x; Initial Catalog = Adventureworks2014; Integrated Security = SSPI";
  36. using (SqlConnection sqlconn = new SqlConnection(constring))
  37. {
  38. 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";
  39. using (SqlCommand sqlcomm = new SqlCommand(commandText, sqlconn))
  40. {
  41. using (SqlDataAdapter sqladap = new SqlDataAdapter(sqlcomm))
  42. {
  43. using (DataSet1 dset1 = new DataSet1())
  44. {
  45. sqladap.Fill(dset1, dset1.Product.TableName);
  46. return dset1.Product;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. public DataTable getDataSet2Data()
  53. {
  54. string constring = "Data Source = x.x.x.x; Initial Catalog = Adventureworks2014; Integrated Security = SSPI";
  55. using (SqlConnection sqlconn = new SqlConnection(constring))
  56. {
  57. string commandText = "SELECT PurchaseOrderID, PurchaseOrderDetailID, OrderQty, ProductID, ReceivedQty, RejectedQty, StockedQty FROM Purchasing.PurchaseOrderDetail";
  58. using (SqlCommand sqlcomm = new SqlCommand(commandText, sqlconn))
  59. {
  60. using (SqlDataAdapter sqladap = new SqlDataAdapter(sqlcomm))
  61. {
  62. using (DataSet2 dset2 = new DataSet2())
  63. {
  64. sqladap.Fill(dset2, dset2.PurchaseOrderDetail.TableName);
  65. return dset2.PurchaseOrderDetail;
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement