本文介绍了C锋利的WPF应用程序和SQL外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有两个表.一个具有另一个的外键.并且有一种形式可以将数据插入具有外键(表1)的表中.我正在从具有主键(table2)和组合框的表中获取数据.
there are two tables. one has foreign key of the other one. and there is a form which inserts data to the table which has foreign key(table1). i am taking data from the table which has primary key(table2) with a combobox.
table1 = (malzID<int,>, sinifID<int,>, marka<nvarchar(50),>
table2 = (sinifID<int,>, sinif<nvarchar(50))>
这是sql插入代码;
here is sql insert code;
SqlCommand ins = new SqlCommand("insert into malzeme (marka, model, aciklama, specNO, seriNO) values ('' " + textBox1.Text + " '' , '' " + textBox2.Text + " '' , '' " + textBox3.Text + " '' , '' " + textBox4.Text + " '' , '' " + textBox5.Text + " '')", sconn);
sconn.Open();
我需要将数据从table2列sinif移到组合框(我已经这样做了),并将其id插入table1列sinifID.问题是;我该怎么办?
在此先感谢,
i need to take data from table2 column sinif to a combobox(i did it already) and insert its id to table1 column sinifID. the question is; what will i do?
thanks in advance,
推荐答案
这篇关于C锋利的WPF应用程序和SQL外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!