Retrieving data from a second table within a dataset
I am using Visual Studio 2010. I created a new project under C# for a Report Application. I have configured my Connection String and DataSet for the Report, with the DataSet containing 2 tables (table1 and table2). (Done via the wizard).
Now the form that was created contains only the data from 1 table (table1), but not the second table (table2). What I want to do is have data from table2 be added to the form to be seen in conjunction with the data from table1. The automatically
generated code is below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ReportsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'CRMDataSet2.AnnotationBase' table. You can move, or remove it, as needed.
this.AnnotationBaseTableAdapter.Fill(this.CRMDataSet2.AnnotationBase);
this.reportViewer1.RefreshReport();
}
}
}
I see where the TableAdapter is filled with the table data from table1. So logically thinking, I figured the same type of Fill needs to be done for table2. I added a line beneath "this.Annotation*..." with the following code:
this.ActivityPointerBaseTableAdapter.Fill(this.CRMDataSet2.ActivityPointerBase);
However the debugger comes up with this:
Error 1 'ReportsApplication1.Form1' does not contain a definition for 'ActivityPointerBaseTableAdapter' and no extension method 'ActivityPointerBaseTableAdapter' accepting a first argument of type 'ReportsApplication1.Form1'
could be found (are you missing a using directive or an assembly reference?)
So I am guessing that Visual Studio did not create a TableAdapter for table2. I've looked at several resources for creating the adapter but those come up with errors also so I figure I am doing something wrong with the creation of it. Can anyone
provide me with code I will need to create that TableAdapter so that I can add the data from it to my report?
Btw at the moment I am just trying to collect all data. Later down the road I will apply filters and parameters for my selection criteria but i just want the data to appear on the form first.
March 10th, 2011 12:13pm