<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDatabase_ADO.net%2FDataView</id>
		<title>Csharp/C Sharp/Database ADO.net/DataView - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDatabase_ADO.net%2FDataView"/>
		<link rel="alternate" type="text/html" href="http://www.nfex.ru/index.php?title=Csharp/C_Sharp/Database_ADO.net/DataView&amp;action=history"/>
		<updated>2026-04-13T20:28:01Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.nfex.ru/index.php?title=Csharp/C_Sharp/Database_ADO.net/DataView&amp;diff=911&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.nfex.ru/index.php?title=Csharp/C_Sharp/Database_ADO.net/DataView&amp;diff=911&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.nfex.ru/index.php?title=Csharp/C_Sharp/Database_ADO.net/DataView&amp;diff=912&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.nfex.ru/index.php?title=Csharp/C_Sharp/Database_ADO.net/DataView&amp;diff=912&amp;oldid=prev"/>
				<updated>2010-05-26T11:42:20Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Create DataView through DataTable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
   class DataViewExample&lt;br /&gt;
   {&lt;br /&gt;
      static void Main()&lt;br /&gt;
      {&lt;br /&gt;
         string connString = &amp;quot;server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI&amp;quot;;&lt;br /&gt;
         string sql = @&amp;quot;select * from employee&amp;quot;;&lt;br /&gt;
         SqlConnection conn = new SqlConnection(connString);&lt;br /&gt;
         try {&lt;br /&gt;
            SqlDataAdapter da = new SqlDataAdapter();&lt;br /&gt;
            da.SelectCommand = new SqlCommand(sql, conn);&lt;br /&gt;
            DataSet ds = new DataSet();&lt;br /&gt;
            da.Fill(ds, &amp;quot;employee&amp;quot;);&lt;br /&gt;
            DataTable dt = ds.Tables[&amp;quot;employee&amp;quot;];&lt;br /&gt;
            DataView dv = new DataView(dt,&amp;quot;lastname = &amp;quot;Z&amp;quot;&amp;quot;, &amp;quot;lastname&amp;quot;, DataViewRowState.CurrentRows);&lt;br /&gt;
            foreach (DataRowView drv in dv)&lt;br /&gt;
            {&lt;br /&gt;
               for (int i = 0; i &amp;lt; dv.Table.Columns.Count; i++){&lt;br /&gt;
                  Console.Write(drv[i] + &amp;quot;\t&amp;quot;);&lt;br /&gt;
               }   &lt;br /&gt;
            }&lt;br /&gt;
         }&lt;br /&gt;
         catch(Exception e)&lt;br /&gt;
         {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Error: &amp;quot; + e);&lt;br /&gt;
         }&lt;br /&gt;
         finally&lt;br /&gt;
         {&lt;br /&gt;
            conn.Close();&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==illustrates the use of a DataView object to   filter and sort rows==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example23_5.cs illustrates the use of a DataView object to&lt;br /&gt;
  filter and sort rows&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
public class Example23_5&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    // formulate a string containing the details of the&lt;br /&gt;
    // database connection&lt;br /&gt;
    string connectionString =&lt;br /&gt;
      &amp;quot;server=localhost;database=Northwind;uid=sa;pwd=sa&amp;quot;;&lt;br /&gt;
    // create a SqlConnection object to connect to the&lt;br /&gt;
    // database, passing the connection string to the constructor&lt;br /&gt;
    SqlConnection mySqlConnection =&lt;br /&gt;
      new SqlConnection(connectionString);&lt;br /&gt;
    // formulate a string containing a SELECT statement&lt;br /&gt;
    string selectString =&lt;br /&gt;
      &amp;quot;SELECT CustomerID, CompanyName, City, Country &amp;quot; +&lt;br /&gt;
      &amp;quot;FROM Customers&amp;quot;;&lt;br /&gt;
    // create a SqlCommand object to hold the SELECT statement&lt;br /&gt;
    SqlCommand mySqlCommand = mySqlConnection.CreateCommand();&lt;br /&gt;
    // set the CommandText property of the SqlCommand object to&lt;br /&gt;
    // the SELECT string&lt;br /&gt;
    mySqlCommand.rumandText = selectString;&lt;br /&gt;
    // create a SqlDataAdapter object&lt;br /&gt;
    SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();&lt;br /&gt;
    // set the SelectCommand property of the SqlAdapter object&lt;br /&gt;
    // to the SqlCommand object&lt;br /&gt;
    mySqlDataAdapter.SelectCommand = mySqlCommand;&lt;br /&gt;
    // create a DataSet object to store the results of&lt;br /&gt;
    // the SELECT statement&lt;br /&gt;
    DataSet myDataSet = new DataSet();&lt;br /&gt;
    // open the database connection using the&lt;br /&gt;
    // Open() method of the SqlConnection object&lt;br /&gt;
    mySqlConnection.Open();&lt;br /&gt;
    // use the Fill() method of the SqlDataAdapter object to&lt;br /&gt;
    // retrieve the rows from the table, storing the rows locally&lt;br /&gt;
    // in a DataTable of the DataSet object&lt;br /&gt;
    Console.WriteLine(&amp;quot;Retrieving rows from the Customers table&amp;quot;);&lt;br /&gt;
    mySqlDataAdapter.Fill(myDataSet, &amp;quot;Customers&amp;quot;);&lt;br /&gt;
    // create a DataView object&lt;br /&gt;
    DataView myDataView =&lt;br /&gt;
      new DataView(myDataSet.Tables[&amp;quot;Customers&amp;quot;]);&lt;br /&gt;
    // set the RowFilter property of the DataView object&lt;br /&gt;
    myDataView.RowFilter = &amp;quot;Country = &amp;quot;UK&amp;quot;&amp;quot;;&lt;br /&gt;
    // set the Sort property of the DataView object&lt;br /&gt;
    myDataView.Sort = &amp;quot;CustomerID ASC&amp;quot;;&lt;br /&gt;
    // display the rows in the DataView object&lt;br /&gt;
    foreach (DataRowView myDataRowView in myDataView)&lt;br /&gt;
    {&lt;br /&gt;
      for (int count = 0; count &amp;lt; myDataView.Table.Columns.Count; count++)&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(myDataRowView[count]);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // close the database connection using the Close() method&lt;br /&gt;
    // of the SqlConnection object&lt;br /&gt;
    mySqlConnection.Close();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==use the Find() and FindRows() methods of a DataView to find DataRowView objects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Data.SqlClient;&lt;br /&gt;
class FindingDataRowViews {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        SqlConnection mySqlConnection =&lt;br /&gt;
          new SqlConnection(&lt;br /&gt;
            &amp;quot;server=localhost;database=Northwind;uid=sa;pwd=sa&amp;quot;&lt;br /&gt;
          );&lt;br /&gt;
        SqlCommand mySqlCommand = mySqlConnection.CreateCommand();&lt;br /&gt;
        mySqlCommand.rumandText =&lt;br /&gt;
          &amp;quot;SELECT CustomerID, CompanyName, Country &amp;quot; +&lt;br /&gt;
          &amp;quot;FROM Customers&amp;quot;;&lt;br /&gt;
        SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();&lt;br /&gt;
        mySqlDataAdapter.SelectCommand = mySqlCommand;&lt;br /&gt;
        DataSet myDataSet = new DataSet();&lt;br /&gt;
        mySqlConnection.Open();&lt;br /&gt;
        mySqlDataAdapter.Fill(myDataSet, &amp;quot;Customers&amp;quot;);&lt;br /&gt;
        mySqlConnection.Close();&lt;br /&gt;
        DataTable customersDT = myDataSet.Tables[&amp;quot;Customers&amp;quot;];&lt;br /&gt;
        string filterExpression = &amp;quot;Country = &amp;quot;UK&amp;quot;&amp;quot;;&lt;br /&gt;
        string sortExpression = &amp;quot;CustomerID&amp;quot;;&lt;br /&gt;
        DataViewRowState rowStateFilter = DataViewRowState.OriginalRows;&lt;br /&gt;
        DataView customersDV = new DataView();&lt;br /&gt;
        customersDV.Table = customersDT;&lt;br /&gt;
        customersDV.RowFilter = filterExpression;&lt;br /&gt;
        customersDV.Sort = sortExpression;&lt;br /&gt;
        customersDV.RowStateFilter = rowStateFilter;&lt;br /&gt;
        foreach (DataRowView myDataRowView in customersDV) {&lt;br /&gt;
            for (int count = 0; count &amp;lt; customersDV.Table.Columns.Count; count++) {&lt;br /&gt;
                Console.WriteLine(myDataRowView[count]);&lt;br /&gt;
            }&lt;br /&gt;
            Console.WriteLine(&amp;quot;&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        int index = customersDV.Find(&amp;quot;BSBEV&amp;quot;);&lt;br /&gt;
        Console.WriteLine(&amp;quot;BSBEV found at index &amp;quot; + index + &amp;quot;\n&amp;quot;);&lt;br /&gt;
        DataRowView[] customersDRVs = customersDV.FindRows(&amp;quot;BSBEV&amp;quot;);&lt;br /&gt;
        foreach (DataRowView myDataRowView in customersDRVs) {&lt;br /&gt;
            for (int count = 0; count &amp;lt; customersDV.Table.Columns.Count; count++) {&lt;br /&gt;
                Console.WriteLine(myDataRowView[count]);&lt;br /&gt;
            }&lt;br /&gt;
            Console.WriteLine(&amp;quot;&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>