Hi... I have related table and I have
ForeignKeyConstraint so when I delete parent table's data,
child table's related data don't delete.
After this I re Run project An occurs Error. My code is like below . thank you...
void
iliskilendir( )
{
try
{
string
sorgu_firma = "select * from firma";
string
sorgu_bocek = "select * from bocek_veri";
adpt_firma = new OleDbDataAdapter(sorgu_firma,
baglan());
adpt_bocek = new OleDbDataAdapter(sorgu_bocek,
baglan());
ds = new
DataSet();
adpt_firma.Fill(ds, "firma");
adpt_bocek.Fill(ds, "bocek_veri");
DataColumn
firma_kolon = ds.Tables["firma"].Columns["firma_ID"];
DataColumn
bocek_kolon = ds.Tables["bocek_veri"].Columns["firma_ID"];
ForeignKeyConstraint
kisitla = new ForeignKeyConstraint(firma_kolon,
bocek_kolon);
kisitla.UpdateRule = Rule.Cascade;
kisitla.DeleteRule = Rule.Cascade;
kisitla.AcceptRejectRule = AcceptRejectRule.Cascade;
ds.Tables["bocek_veri"].Constraints.Add(kisitla);
ds.EnforceConstraints = true;
vt_iliski = new DataRelation( "firma_To_bocek_veri" , firma_kolon,
bocek_kolon,true );
ds.Relations.Add(vt_iliski);
yonet_firma = new BindingSource(ds,
ds.Tables["firma"].ToString());
yonet_bocek = new BindingSource(yonet_firma,
"firma_To_bocek_veri");
//
TextBoxlar firma tablosunun alanlarina baglaniyor
firma_IDTextBox.DataBindings.Add("Text",
yonet_firma, "firma_ID");
firma_adiTextBox.DataBindings.Add("Text",
yonet_firma, "firma_adi");
firma_iliTextBox.DataBindings.Add("Text",
yonet_firma, "firma_ili");
firma_telTextBox.DataBindings.Add("Text", yonet_firma, "firma_tel");
firma_adresiTextBox.DataBindings.Add("Text",
yonet_firma, "firma_adresi");
firma_is_tanimiTextBox.DataBindings.Add("Text",
yonet_firma, "firma_is_tanimi");
kayit_tarihiDateTimePicker.DataBindings.Add("text", yonet_firma, "kayit_tarihi");
adpt_firma.Dispose();
adpt_bocek.Dispose();
}
catch
(Exception hata)
{
MessageBox.Show("Hata 3 olustu :" + hata.TargetSite );
} }