ASPX Page:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HealthtipsConnectionString"].ToString());
SqlCommand cmd;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDisplay_Click(object sender, EventArgs e)
{
try
{
con.Open();
string str = "Select * From Tbl_Users";
cmd = new SqlCommand(str, con);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
da.Fill(ds);
if (ds.Tables[0].Columns.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
ReportDataSource rds = new ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewver1.LocalReport.DataSources.Clear();
ReportViewver1.LocalReport.DataSources.Add(rds);
ReportViewver1.LocalReport.Refresh();
}
}
}
catch (Exception ex)
{
lblerrmsg.Text = ex.Message;
}
}
}
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HealthtipsConnectionString"].ToString());
SqlCommand cmd;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDisplay_Click(object sender, EventArgs e)
{
try
{
con.Open();
string str = "Select * From Tbl_Users";
cmd = new SqlCommand(str, con);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
da.Fill(ds);
if (ds.Tables[0].Columns.Count > 0)
{
if (ds.Tables[0].Rows.Count > 0)
{
ReportDataSource rds = new ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewver1.LocalReport.DataSources.Clear();
ReportViewver1.LocalReport.DataSources.Add(rds);
ReportViewver1.LocalReport.Refresh();
}
}
}
catch (Exception ex)
{
lblerrmsg.Text = ex.Message;
}
}
}
No comments:
Post a Comment