C# 今天在VS2015 Professional中发布,并通过导航到Form1.cs(Design)修复了该问题,使用操作箭头选择正确的数据源并最终重新绑定。请参见下图,并按照相应的红色、绿色和紫色指示查看我的解决方案步骤
谢谢。现在,为什么微软不能在他们的错误消息中加入这个建议呢。C# 今天在VS2015 Professional中发布,并通过导航到Form1.cs(Design)修复了该问题,使用操作箭头选择正确的数据源并最终重新绑定。请参见下图,并按照相应的红色、绿色和紫色指示查看我的解决方案步骤,c#,reportviewer,rdlc,C#,Reportviewer,Rdlc,谢谢。现在,为什么微软不能在他们的错误消息中加入这个建议呢。 using Microsoft.Reporting.WinForms; //------------------------------------------------------------------ // <copyright company="Microsoft"> // Copyright (c) Microsoft. All rights reserved. // </copyright&g
using Microsoft.Reporting.WinForms;
//------------------------------------------------------------------
// <copyright company="Microsoft">
// Copyright (c) Microsoft. All rights reserved.
// </copyright>
//------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ReportsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.reportViewer1.RefreshReport();
}
private void button1_Click(object sender, EventArgs e)
{
System.Data.DataSet ds = GetDataSet();
//reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportDataSource rds = new ReportDataSource("ProductsDataSet", ds.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(rds);
this.bindingSource1.DataSource = rds;
this.reportViewer1.RefreshReport();
}
private System.Data.DataSet GetDataSet()
{
System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection("Data Source=DELL;Initial Catalog=Products;Integrated Security=True");
sqlConn.Open();
string sql= string.Format ( @"select o.[User], o.OrderDate, o.Quantity, o.OrderDetail, c.ShopName, c.[Address], c.City, c.Ph, p.* from dbo.Clients c,dbo.Product_Service o,Product_D p,Junction j where o.ClientId = c.ClientId
and o.ProductId = j.ProductId
and j.PCode = p.PCode
and o.ClientId = 41
and o.OrderDate='11/9/2012';");
System.Data.SqlClient.SqlDataAdapter ad = new System.Data.SqlClient.SqlDataAdapter(sql, sqlConn);
System.Data.DataSet ds = new System.Data.DataSet();
ad.Fill(ds);
sqlConn.Close();
return ds;
}
}
}
ReportDataSource rds = new ReportDataSource("Product_Detail", ds.Tables[0]);
Dim rptDataSource As ReportDataSource
Try
With Me.ReportViewer1.LocalReport
ReportViewer1.LocalReport.ReportPath = Application.StartupPath & "\RTFLS\Report1.rdlc"
'.DataSources.Clear()
End With
Dim ds As New POAS.CustomersTotalPayment
Dim da As New POAS.CustomersTotalPaymentTableAdapters.PAYMENTSTATUSTableAdapter
da.Fill(ds.PAYMENTSTATUS)
rptDataSource = New ReportDataSource("CustomersTotalPayment", ds.Tables("PAYMENTSTATUS"))
Me.ReportViewer1.LocalReport.DataSources.Add(rptDataSource)
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Me.ReportViewer1.RefreshReport()
private void rptForm_Load(object sender, EventArgs e) {
this.vwrpt_TableAdapter1.Fill(this.DataSet1.vwDataset);
}
Imports Microsoft.Reporting.WebForms
Partial Class Rpt_reports
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim ds As New Custamer
'da.Fill(ds.Tables("custamer")
Dim path As String = Server.MapPath("customerinfo.rdlc")
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.ReportPath = path
ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("Rpt_reports", ds.Tables("Custamer")))
ReportViewer1.LocalReport.Refresh()
End If
End Sub
'Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'End Sub
End Class