我想在数据集表上实现sql插入触发器。数据表插入触发器
我的应用程序有两个数据集表:
-- Table: Artikli -- IDB - int,autoincrement Sifra - int, primary key Naziv - string Cena - double PS - string
-- Table: PodArtikli -- IDB - int,autoincrement,primary key Sifra - int Naziv - string Cena - double Kolicina - int Ukupno - computed column (Cena*Kolicina) Pakovanje - double Jed.Mere - string PLU - string, unique Cena_Po_Meri - computed column (1000/Pakovanje * Cena)
其中父表是Artikli
和子表是PodArtikli
上Sifra
列,这些表是通过外键约束相关联。 我想,当Artikli
中新增一行时,会自动在PodArtikli
表中添加新行,其中Sifra,Naziv
和Cena
的值来自于Artikli
表中添加的行。
数据集表中的数据显示在DataGridView中。 在按钮btnizmene
的单击事件我有以下代码:
Dim novirow As DataRow = dspetrovac.Artikli.NewRow
novirow("Sifra") = grdpodaci.Item(1, grdpodaci.CurrentRow.Index).Value
novirow("Naziv") = grdpodaci.Item(2, grdpodaci.CurrentRow.Index).Value
novirow("Cena") = grdpodaci.Item(3, grdpodaci.CurrentRow.Index).Value
novirow("PS") = grdpodaci.Item(4, grdpodaci.CurrentRow.Index).Value
触发器通常实现在数据库中,虽然数据表呢有一些事件。如果DGV绑定到数据源,则不必手动将数据传送到newRow项目 – Plutonix
我也试过TableNewRow事件,但没有任何结果。 – Gruja82