Glossary Item Box
In addition to using a data set, the report's data source can be set to a data view. This can be useful for creating reports containing filtered information. To use the data view in the report, set the report's DataSource property to the data view created from the filtered data set (see Using a Data Set for more information).
The following example shows what the code for the method looks like.
' Visual Basic
Dim m_dbPath As String
Dim usView As New DataView()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
m_dbPath = getDatabasePath()
Me.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=" + m_dbPath + "\\NWIND.MDB;Persist Security Info=False"
Me.oleDbDataAdapter1.Fill(Me.dataSet11)
usView = me.dataSet11.Tables("employees"))
usView.RowFilter = "Country = 'USA'"
Me.dataGrid2.DataSource = usView
End Sub
//C#
DataView usView;
private void Form1_Load(object sender, System.EventArgs e)
{
string m_dbPath = getDatabasePath();
this.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" + m_dbPath + "\\NWIND.MDB;Persist Security Info=False";
this.oleDbDataAdapter1.Fill(this.dataSet11);
usView = new DataView(this.dataSet11.Tables["employees"]);
usView.RowFilter = "Country ='USA'";
this.dataGrid2.DataSource = usView;
}
See Also |
Getting Started | Using the DataSource Icon | Using a Data Set
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.