如:dataset1.tables[0] 将光标定位到 mcode="abc"的记录,并修改此行数据。
10 个解决方案
#1
private void AcceptChanges()
{
DataSet myDataSet;
myDataSet = new DataSet();
// Not shown: methods to fill the DataSet with data.
DataTable t;
t = myDataSet.Tables["Suppliers"];
// Add a DataRow to a table.
DataRow myRow;
myRow = t.NewRow();
myRow["CompanyID"] = "NWTRADECO";
myRow["CompanyName"] = "NortWest Trade Company";
// Add the row.
t.Rows.Add( myRow );
// Calling AcceptChanges on the DataSet causes AcceptChanges to be
// called on all subordinate objects.
myDataSet.AcceptChanges();
}
{
DataSet myDataSet;
myDataSet = new DataSet();
// Not shown: methods to fill the DataSet with data.
DataTable t;
t = myDataSet.Tables["Suppliers"];
// Add a DataRow to a table.
DataRow myRow;
myRow = t.NewRow();
myRow["CompanyID"] = "NWTRADECO";
myRow["CompanyName"] = "NortWest Trade Company";
// Add the row.
t.Rows.Add( myRow );
// Calling AcceptChanges on the DataSet causes AcceptChanges to be
// called on all subordinate objects.
myDataSet.AcceptChanges();
}
#2
修改呢,如何做?如何定位到想要的记录处?
#3
mydataset.tables[0].rows[0][0] 这样就可以任意的定位了
#4
问题是只知道想要的指定column的值,而不知row的序号。
#5
建议使用:DataTable.Select
#6
DataRow[] foundRows = myTable.Select(mcode="abc);
#7
对 select 出来的rows进行更改,如何update到原来的table上 ?(不是update到数据库)
#8
help me.
#9
我也想知道啊
#10
private void button1_Click(object sender, System.EventArgs e)
{
DataRow[] findrows;
findrows=this.dataSet11.Tables [0].Select ("name='leo'");
if (findrows.Length >0)
{
findrows[0][1]="90";
//我的Table是这样的:|name|mark|
// |leo | 30|
//click button 后,name=leo;mark=90;Table自动更新。
}
}
{
DataRow[] findrows;
findrows=this.dataSet11.Tables [0].Select ("name='leo'");
if (findrows.Length >0)
{
findrows[0][1]="90";
//我的Table是这样的:|name|mark|
// |leo | 30|
//click button 后,name=leo;mark=90;Table自动更新。
}
}
#1
private void AcceptChanges()
{
DataSet myDataSet;
myDataSet = new DataSet();
// Not shown: methods to fill the DataSet with data.
DataTable t;
t = myDataSet.Tables["Suppliers"];
// Add a DataRow to a table.
DataRow myRow;
myRow = t.NewRow();
myRow["CompanyID"] = "NWTRADECO";
myRow["CompanyName"] = "NortWest Trade Company";
// Add the row.
t.Rows.Add( myRow );
// Calling AcceptChanges on the DataSet causes AcceptChanges to be
// called on all subordinate objects.
myDataSet.AcceptChanges();
}
{
DataSet myDataSet;
myDataSet = new DataSet();
// Not shown: methods to fill the DataSet with data.
DataTable t;
t = myDataSet.Tables["Suppliers"];
// Add a DataRow to a table.
DataRow myRow;
myRow = t.NewRow();
myRow["CompanyID"] = "NWTRADECO";
myRow["CompanyName"] = "NortWest Trade Company";
// Add the row.
t.Rows.Add( myRow );
// Calling AcceptChanges on the DataSet causes AcceptChanges to be
// called on all subordinate objects.
myDataSet.AcceptChanges();
}
#2
修改呢,如何做?如何定位到想要的记录处?
#3
mydataset.tables[0].rows[0][0] 这样就可以任意的定位了
#4
问题是只知道想要的指定column的值,而不知row的序号。
#5
建议使用:DataTable.Select
#6
DataRow[] foundRows = myTable.Select(mcode="abc);
#7
对 select 出来的rows进行更改,如何update到原来的table上 ?(不是update到数据库)
#8
help me.
#9
我也想知道啊
#10
private void button1_Click(object sender, System.EventArgs e)
{
DataRow[] findrows;
findrows=this.dataSet11.Tables [0].Select ("name='leo'");
if (findrows.Length >0)
{
findrows[0][1]="90";
//我的Table是这样的:|name|mark|
// |leo | 30|
//click button 后,name=leo;mark=90;Table自动更新。
}
}
{
DataRow[] findrows;
findrows=this.dataSet11.Tables [0].Select ("name='leo'");
if (findrows.Length >0)
{
findrows[0][1]="90";
//我的Table是这样的:|name|mark|
// |leo | 30|
//click button 后,name=leo;mark=90;Table自动更新。
}
}