Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. how to connect reportviewer to dataset

how to connect reportviewer to dataset

Scheduled Pinned Locked Moved Windows Forms
helpcsharpdatabaselinqdesign
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vikas shukla
    wrote on last edited by
    #1

    hi sir i am connecting the reportviewer to dataset but i am fail.i am using following code.please help me. using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Microsoft.Reporting.WebForms; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ReportViewer1.Visible = false; } protected void Button1_Click(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { ReportViewer1.Visible = true; SqlConnection con = new SqlConnection("server=DC-12\\SQLSERVER2005;uid=sa;pwd=start;database=Vikas_Data"); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "seldata"; string pn = TextBox1.Text; cmd.Parameters.AddWithValue("@pn", pn); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; SqlDataAdapter adap = new SqlDataAdapter(); adap.SelectCommand = cmd; DataSet ds = new DataSet (); adap.Fill(ds, "table"); ReportViewer1.LocalReport.ReportPath = "MyFirst.rdlc"; ReportDataSource rds = new ReportDataSource(); rds.value=ds.Tables[0]; ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.Refresh(); } } there is no error .but data will not be show in report viewer. please help me .as soon as possible .what may be the issue.

    I 1 Reply Last reply
    0
    • V vikas shukla

      hi sir i am connecting the reportviewer to dataset but i am fail.i am using following code.please help me. using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Microsoft.Reporting.WebForms; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ReportViewer1.Visible = false; } protected void Button1_Click(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { ReportViewer1.Visible = true; SqlConnection con = new SqlConnection("server=DC-12\\SQLSERVER2005;uid=sa;pwd=start;database=Vikas_Data"); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "seldata"; string pn = TextBox1.Text; cmd.Parameters.AddWithValue("@pn", pn); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; SqlDataAdapter adap = new SqlDataAdapter(); adap.SelectCommand = cmd; DataSet ds = new DataSet (); adap.Fill(ds, "table"); ReportViewer1.LocalReport.ReportPath = "MyFirst.rdlc"; ReportDataSource rds = new ReportDataSource(); rds.value=ds.Tables[0]; ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.Refresh(); } } there is no error .but data will not be show in report viewer. please help me .as soon as possible .what may be the issue.

      I Offline
      I Offline
      Illuminaries
      wrote on last edited by
      #2

      You might want to try clearing the existing data sources first with Me.ReportViewer1.LocalReport.DataSources.Clear() and possibly in the form.designer.vb comment out the lines which would have been added if/when you selected the report using the ReportViewer Tasks box 'Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource and 'ReportDataSource1.Value = 'Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1) I have found that almost every problem I've had with report viewer not displaying the report was to do with data in some way or another. Have you confirmed that your adap.fill line is actually putting some records into the dataset? Hope this is of some help.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups