G
Guest
Hi,
I've used xsd to generate a dataset from an xml file. In my program I
populate the dataset with data from a database. Well my problem is as follows:
The xsd has added an AddRow method for my schema. The method is as follows:
public BankaRow AddBankaRow(string BankaAdi, int AlacakCekAdeti,
int AlacakIadeliCekAdeti, int VerecekCekAdeti, int VerecekIadeliCekAdeti,
System.Decimal ToplamBorc, System.Decimal ToplamAlacak, System.Decimal
KalanBorc, System.Decimal KalanAlacak, string BankaId, BankalarRow
parentBankalarRowByBankalar_Banka) {
BankaRow rowBankaRow = ((BankaRow)(this.NewRow()));
rowBankaRow.ItemArray = new object[] {
BankaAdi,
AlacakCekAdeti,
AlacakIadeliCekAdeti,
VerecekCekAdeti,
VerecekIadeliCekAdeti,
ToplamBorc,
ToplamAlacak,
KalanBorc,
KalanAlacak,
BankaId,
parentBankalarRowByBankalar_Banka[0]};
this.Rows.Add(rowBankaRow);
return rowBankaRow;
}
In my code I add the rows as follows:
ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
From the db:
dsBankaSube1.BETSBankalar[0].BankaAdi is 1. Banka and
dsBankaSube1.BETSBankalar[1].BankaAdi is 2. Banka
however the dataset output for BankaRow[0].BankaAdi is 2. Banka
and BankaRow[1].BankaAdi is also 2. Banka
to capture the problem in depth I have changed the code to this:
BankaRow temp=null;
for(int i=0;i<dsBankaSube1.BETSBankalar.Count;i++){
if(i==0)
{
//temp is an instace for
BankaRow temp=ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
}
else
{ ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
}
Console.WriteLine(temp.BankaAdi);
}
Well the output is:
1. Banka
2. Banka
2. Banka
2. Banka
....
And goes on with 2. Banka.
I believe the call to dataTable's NewRow method doesn't return a newly
generated row instace. Thus the previous datarow gets overwritten. How
come? Is this a bug in .Net framework (I'm using 1.1). Or if not what I'm
doing wrong?
I've used xsd to generate a dataset from an xml file. In my program I
populate the dataset with data from a database. Well my problem is as follows:
The xsd has added an AddRow method for my schema. The method is as follows:
public BankaRow AddBankaRow(string BankaAdi, int AlacakCekAdeti,
int AlacakIadeliCekAdeti, int VerecekCekAdeti, int VerecekIadeliCekAdeti,
System.Decimal ToplamBorc, System.Decimal ToplamAlacak, System.Decimal
KalanBorc, System.Decimal KalanAlacak, string BankaId, BankalarRow
parentBankalarRowByBankalar_Banka) {
BankaRow rowBankaRow = ((BankaRow)(this.NewRow()));
rowBankaRow.ItemArray = new object[] {
BankaAdi,
AlacakCekAdeti,
AlacakIadeliCekAdeti,
VerecekCekAdeti,
VerecekIadeliCekAdeti,
ToplamBorc,
ToplamAlacak,
KalanBorc,
KalanAlacak,
BankaId,
parentBankalarRowByBankalar_Banka[0]};
this.Rows.Add(rowBankaRow);
return rowBankaRow;
}
In my code I add the rows as follows:
ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
From the db:
dsBankaSube1.BETSBankalar[0].BankaAdi is 1. Banka and
dsBankaSube1.BETSBankalar[1].BankaAdi is 2. Banka
however the dataset output for BankaRow[0].BankaAdi is 2. Banka
and BankaRow[1].BankaAdi is also 2. Banka
to capture the problem in depth I have changed the code to this:
BankaRow temp=null;
for(int i=0;i<dsBankaSube1.BETSBankalar.Count;i++){
if(i==0)
{
//temp is an instace for
BankaRow temp=ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
}
else
{ ornekES1.Banka.AddBankaRow(dsBankaSube1.BETSBankalar.BankaAdi,(int)alacaks[0],(int)alacaksIadeli[0],(int)verens[0],(int)verensIadeli[0],tborc,talacak,kborc,kalacak,dsBankaSube1.BETSBankalar.BETSBankaId,ornekES1.Bankalar[0]);
}
Console.WriteLine(temp.BankaAdi);
}
Well the output is:
1. Banka
2. Banka
2. Banka
2. Banka
....
And goes on with 2. Banka.
I believe the call to dataTable's NewRow method doesn't return a newly
generated row instace. Thus the previous datarow gets overwritten. How
come? Is this a bug in .Net framework (I'm using 1.1). Or if not what I'm
doing wrong?