Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 wpf 应用程序中,我想将与所选值(下拉列表中的名称)关联的 ID 插入到另一个表中。例如,从列表中选择 Michael。Michaels PK 为 1。当我单击添加按钮时,1 成为另一个表中的 fk,该表将链接 Michaels 地址详细信息。
cmd = new SqlCommand("Insert into Table2 (fkID) SELECT DISTINCT ID from Table1 where ID =('" + cbName.Text + "')", sc);;
恐怕您可能想提供更多信息,以便这里的好人可以尝试回答。
要将 Table2 中的所有外键插入另一个表,比如 Table1,您可能正在寻找类似的 SQL
INSERT INTO Table2 (ForeignKeyID) SELECT DISTINCT ForeignKeyID FROM Table1 WHERE SomeIDField = 'SomeValue' ?