سلام بر برنامه نویسان عزیز ایران زمین 😉 در این مطلب کد ساخت DataView از DataTable در c#.net را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد ساخت DataView از DataTable در c#.net :
using System;
using System.Data;
using System.Data.SqlClient;
class MainClass
{
static void Main(string[] args)
{
string connString = @"server = .\sqlexpress;integrated security = true;database = northwind";
string sql = @"select contactname, country from customers";
SqlConnection conn = new SqlConnection(connString);
try
{
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "customers");
DataTable dt = ds.Tables["customers"];
DataView dv = new DataView(dt,"country = 'Germany'","country",DataViewRowState.CurrentRows);
foreach (DataRowView drv in dv)
{
using System.Data;
using System.Data.SqlClient;
class MainClass
{
static void Main(string[] args)
{
string connString = @"server = .\sqlexpress;integrated security = true;database = northwind";
string sql = @"select contactname, country from customers";
SqlConnection conn = new SqlConnection(connString);
try
{
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "customers");
DataTable dt = ds.Tables["customers"];
DataView dv = new DataView(dt,"country = 'Germany'","country",DataViewRowState.CurrentRows);
foreach (DataRowView drv in dv)
{