获取不同版本的DataRowusing System;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Collections;
using System.Data;
using ZZ.Net;
using ZZ.DAL;
using ZZ.WMI;
using System.Xml;
using System.Management;
using System.Net;
namespace ZZ
{
class ZZConsole
{
[STAThread]
static void Main(string[] args)
{
DataSet ds = new DataSet();
CreatDataSetSchema(ds);
InitData(ds);
DataRow drdel = ds.Tables["Hosts"].Rows[0];
drdel.Delete();
Console.WriteLine(drdel.HasVersion(DataRowVersion.Default).ToString());
foreach(DataRow dr in ds.Tables["Hosts"].GetChanges(DataRowState.Deleted).Rows)
{
//if(dr.HasVersion(DataRowVersion.Current))
//{
Console.WriteLine((string)dr["HId"]);
Console.WriteLine(dr["IsLocal",DataRowVersion.Original].ToString());
//}
}
Console.WriteLine("end");
Console.ReadLine();
}
//初始化数据集结构
private static void CreatDataSetSchema(DataSet ds)
{
DataTable dt = new DataTable("Hosts");
DataColumn dc = new DataColumn("HId",typeof(String));
dt.Columns.Add(dc);
dc = new DataColumn("IsLocal",typeof(Boolean));
dt.Columns.Add(dc);
ds.Tables.Add(dt);
}
//加入数据
private static void InitData(DataSet ds)
{
DataRow hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.229";
hostsRow["IsLocal"] = true;
ds.Tables["Hosts"].Rows.Add(hostsRow); hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.231";
hostsRow["IsLocal"] = false;
ds.Tables["Hosts"].Rows.Add(hostsRow); hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.233";
hostsRow["IsLocal"] = false;
ds.Tables["Hosts"].Rows.Add(hostsRow);
}
}
}
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Collections;
using System.Data;
using ZZ.Net;
using ZZ.DAL;
using ZZ.WMI;
using System.Xml;
using System.Management;
using System.Net;
namespace ZZ
{
class ZZConsole
{
[STAThread]
static void Main(string[] args)
{
DataSet ds = new DataSet();
CreatDataSetSchema(ds);
InitData(ds);
DataRow drdel = ds.Tables["Hosts"].Rows[0];
drdel.Delete();
Console.WriteLine(drdel.HasVersion(DataRowVersion.Default).ToString());
foreach(DataRow dr in ds.Tables["Hosts"].GetChanges(DataRowState.Deleted).Rows)
{
//if(dr.HasVersion(DataRowVersion.Current))
//{
Console.WriteLine((string)dr["HId"]);
Console.WriteLine(dr["IsLocal",DataRowVersion.Original].ToString());
//}
}
Console.WriteLine("end");
Console.ReadLine();
}
//初始化数据集结构
private static void CreatDataSetSchema(DataSet ds)
{
DataTable dt = new DataTable("Hosts");
DataColumn dc = new DataColumn("HId",typeof(String));
dt.Columns.Add(dc);
dc = new DataColumn("IsLocal",typeof(Boolean));
dt.Columns.Add(dc);
ds.Tables.Add(dt);
}
//加入数据
private static void InitData(DataSet ds)
{
DataRow hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.229";
hostsRow["IsLocal"] = true;
ds.Tables["Hosts"].Rows.Add(hostsRow); hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.231";
hostsRow["IsLocal"] = false;
ds.Tables["Hosts"].Rows.Add(hostsRow); hostsRow = ds.Tables["Hosts"].NewRow();
hostsRow["HId"] = "192.192.132.233";
hostsRow["IsLocal"] = false;
ds.Tables["Hosts"].Rows.Add(hostsRow);
}
}
}
得到这个DataView不就可以得到Row了
然后用 Row["xxx",DataRowVersion.Original] 得到原值
string SQL="Select A from TB
DataSet ds=new DataSet ();
ds=adoT.adoT.ExecuteDataSet (SQL);
string A=ds.Tables [0].Rows [0]["A",DataRowVersion.Original].ToString ();修改后可在dataGrid1_CurrentCellChanged事件中获取
A=this.dataGrid1[this.dataGrid1.CurrentCell.RowNumber,0].ToString();