protected void Page_Load(object sender, EventArgs e)
{
conn = new OdbcConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
if (!Page.IsPostBack)
{
runRptViewer();
}
}
<pre></pre>
private void rptGetDataset()
{
DataSet ds = new DataSet();
ds.DataSetName = "dsNewDataSet";
string sql = "";
sql = "SELECT ID, CLIENT_ID, AGENT_ID FROM TBLMAILDELETED";
OdbcDataAdapter da = new OdbcDataAdapter(sql, conn);
ds.GetXmlSchema();
da.Fill(ds);
ds.WriteXmlSchema(_path + "/App_Code/Ds.xsd");
ds.WriteXml(_path + "/App_Code/Ds.xml");
}
private DataTable getData()
{
DataSet dss = new DataSet();
string sql = "";
sql = "SELECT ID, CLIENT_ID, AGENT_ID FROM TBLMAILDELETED";
OdbcDataAdapter da = new OdbcDataAdapter(sql, conn);
da.Fill(dss);
DataTable dt = dss.Tables[0];
return dt;
}
private void runRptViewer()
{
this.ReportViewer1.Reset();
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
ReportDataSource rds = new ReportDataSource("dsNewDataSet_Table", getData());
this.ReportViewer1.LocalReport.DataSources.Clear();
this.ReportViewer1.LocalReport.DataSources.Add(rds);
this.ReportViewer1.DataBind();
this.ReportViewer1.LocalReport.Refresh();
}