This row already belongs to another table
gibi bir hata vermektir. Yani;
C#İşlemini yapamamaktayız. Sebebi ise ADD metodunu kullandığımızda, dt1 in referanslarıyla dt2 ye ekleme yapmaya çalışmasıdır.
foreach(DataRow row in dt1.Rows){
if(......){
dt2.Rows.Add(row);
}
}
VB.net
for each row as datarow in dt1.rows
if .... then
dt2.rows.add(row)
endif.
next.
Burada kullanacağımız metod, datatable nesnesinin IMPORTROW metodudur.
Örnek;
C#VB.NET
DataTable dt1 = ds.Tables[0];
DataTable dt2 = new DataTable();
dt2 = dt1.Clone(); "sütünların aynı olması için clone şart
foreach(DataRow row in dt1.Rows){
if(......){
dt2.ImportRow(row);
}
}
dim dt1 as datatable = ds.tables(0)
dim dt2 as new datatable
dt2 = dt1.clone
for each row as datarow in dt1.rows
if ..... then
dt2.ImportRow(row)
endif
next
iyi çalışmalar & attığınız şutlara paslara dikkat edin :).
3 yorum:
hacı bu importrow yemedi
Oldu teşekkürler.
Tableau Data Visualization Software
SQIAR (http://www.sqiar.com/solutions/technology/tableau) is a leading Business Intelligence company and provides Tableau Software consultancy across United Kingdom and USA.
Yorum Gönder