MikeMCSD
asked on
Delete a row in one dataset that matches the row of another dataset
I need to delete a row in one dataset that matches the row of another dataset :
Dim row As DataRow
For Each row In DSTemp.Rows
. . . .
if condition . . .
>> I want to remove a row in "DataSet1" that matches the current row in "DSTemp", above
DataSet1.Tables(0).Rows.Re move( -- the row that matches DSTemp -- ) ???
Note: datasets DSTemp and DataSet1 are identical
Is it possible to get the "index" or current position of DSTemp and set it to DataSet1?
I have the primary key field: row("ProductID") thanks
Dim row As DataRow
For Each row In DSTemp.Rows
. . . .
if condition . . .
>> I want to remove a row in "DataSet1" that matches the current row in "DSTemp", above
DataSet1.Tables(0).Rows.Re
Note: datasets DSTemp and DataSet1 are identical
Is it possible to get the "index" or current position of DSTemp and set it to DataSet1?
I have the primary key field: row("ProductID") thanks
ASKER
thanks Sandee . . but this is a Windows app. so I can't use Session, and
I'm using VB . . so I'm sure how to convert a lot of it.
I'm using VB . . so I'm sure how to convert a lot of it.
ok u can skip the session actuaaly i have implemented this code in Webapplication on Button click, and for retaining the dataset i am using the session.
u can jst remove the session veriable and write the remaining code in the VB
and if u want take this link for C# to VB convertion
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx
SandeepRR
u can jst remove the session veriable and write the remaining code in the VB
and if u want take this link for C# to VB convertion
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx
SandeepRR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I got the solution for ur problem
u have to write the code for doing that operation the caode will be as follows,
--------------------------
DataSet ds = new DataSet();
ds = (DataSet)Session["Dataview
DataSet ds2 =new DataSet();
ds2 = (DataSet)Session["Data"];
for(int i=0; i<=ds.Tables[0].Rows.Count
{
DataRow re;
re = ds.Tables[0].Rows[i];
for(int j=0; j<=ds.Tables[0].Rows.Count
{
DataRow re1;
re1 = ds2.Tables[0].Rows[j];
if (re[0].ToString() == re1[0].ToString()) {
ds2.Tables[0].Rows.RemoveA
DataGrid2.DataSource = ds2;
DataGrid2.DataBind();
}
}
}
--------------------------
actauly i was calling this method on two dataset
ds and ds1
ds has 2 rows and ds1 has 4 rows out of witch 2 are iedentical to the ds rows(Both the database has onle one table and with same schema)
and calles this code on button click
ans used to session veriable to get the dataset back in the dataset object,
for the folowing line of code
u might have to change the value in place of 0 actually it represent the primary key column in the table.
if (re[0].ToString() == re1[0].ToString())
Regards
SandeepRR