Results 1 to 3 of 3

Thread: Dataset problem

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Dataset problem

    Hello everybody,

    I added a DataSet ReportsDataSet.xsd in my project and added one DataTable named dtClients with 9 columns. I added a crystal report and designed it using this data table. Now I want to fill the data table to show the results in crystal reports. Following is the code I am using to fill the data table.

    Code:
                ReportsDataSet ds = new ReportsDataSet();
    
                DataRow dr;
                for (int i = 0; i < dtClients.Rows.Count; i++)
                {
                    dr = ds.dtClients.NewRow();
                    dr["ClientNumber"] = dtClients.Rows[i]["ClientNumber"].ToString();
                    dr["From"] = dtClients.Rows[i]["From"].ToString();
                    dr["ClientName"] = dtClients.Rows[i]["ClientName"].ToString();
                    dr["Person"] = dtClients.Rows[i]["Person"].ToString();
                    dr["Address"] = dtClients.Rows[i]["Address"].ToString();
                    dr["Near"] = dtClients.Rows[i]["Near"].ToString();
                    dr["Phone"] = dtClients.Rows[i]["Phone"].ToString();
                    dr["Cell"] = dtClients.Rows[i]["Cell"].ToString();
                    dr["Email"] = dtClients.Rows[i]["Email"].ToString();
                    ds.dtClients.Rows.Add(dr);
                    ds.dtClients.AcceptChanges();
                }
    But the data doesn't show up in the report. I need to know what I am doing wrong. Any idea?

    Thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Dataset problem

    Is the report bound to that DataSet? I'll wager not, given that it's create new in that code.

    I don't use CR but, in general, either you need to add the DataSet in the designer and bind it to the report in the designer, or else you need to create the DataSet in code and bind it to the report in code.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Dataset problem

    I have created DataSet using the designer and I added a Datatable in the data set using the designer, and I bound the crystal report designer directly with the dataset. But I am populating the DataSet through code as mentioned above.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width