日期:2014-05-19  浏览次数:20842 次

问一下rdlc报表的问题
VS2005中的rdlc报表   是一个   XML文件
我用向导工具生成的   但是文件中会有连接数据库的   字符串   中间还包含着帐号密码等等
请问怎样安全的使用rdlc啊?

------解决方案--------------------
那个密码信息应当是可以去掉的,只在设计时有用,运行时没有用.
------解决方案--------------------
这是我用来调用RDLC报表的源代码,只要在程序中给reportViewer.LocalReport.ReportPath指定好相应的报表文件,用reportViewer.LocalReport.DataSources.Add指定好已经查出来的数据源,就可以正常显示了。不过要记得,数据源的名字要和你在RDLC报表文件中用的数据源的名字相同。
用这种方法,根本不会在RDLC文件中出现连接字符串之类的东西。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace Report
{
public partial class frmReport : Form
{
DataTable dt = new DataTable();
public frmReport(DataTable datatable)
{
InitializeComponent();
dt = datatable;
}

private void frmReport_Load(object sender, EventArgs e)
{

// Set Processing Mode

reportViewer.ProcessingMode = ProcessingMode.Local;


// Set RDL file

reportViewer.LocalReport.ReportPath = "Report.rdlc ";

// Supply a DataTable corresponding to each report dataset

reportViewer.LocalReport.DataSources.Add(new ReportDataSource( "DataTable ", dt));

// Add the reportviewer to the form

reportViewer.Dock = DockStyle.Fill;
this.Controls.Add(reportViewer);

// Process and render the report

reportViewer.RefreshReport();
}
}
}