c#连接表插入表单 [英] c# junction table insert form

查看:71
本文介绍了c#连接表插入表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解释一下自己:



表:



http://i.stack.imgur .com / fsT5R.png



专辑保存有关专辑的信息,Album_Artiest是联结表,Artiest保留艺术家名称。



我已经在C#中添加了一个表单来添加艺术家。现在我需要一个表单来添加相册。我使用数据集和tableadapter向导,然后从表单上的数据源拖放以生成表单。现在我的问题:



我需要拥有专辑中的所有专栏,但只有艺术家的ArtiestNaam。这是一个组合框,所以我可以从那张桌子中选择一个艺术家。



当我保存它时,它应该将AlbumId连接到联结表中的特定ArtiestId。 br />


我做了一些研究,发现我应该使用存储过程。有人可以帮帮我吗?

To explain myself:

tables:

http://i.stack.imgur.com/fsT5R.png

Album holds information about albums, Album_Artiest is a junction table and Artiest holds the Artists name.

I already made a form in C# to add Artists. Now i need a form to add Albums. I use the dataset and tableadapter wizard and then drag and drop from datasource on the form to generate the form. Now my problem:

I need to have all the columns from album but only the ArtiestNaam from Artiest. And this in a combobox so i can select an artist from that table.

When i save it it should connect that AlbumId to that specific ArtiestId in the junction table.

I did some research and i found that i should use stored procedures. Could somebody help me?

推荐答案

你想从Artiest DataTable填充艺术家的DropDown。为此,请将Artist DataTable设置为DropDown。

要保存数据,必须将它们插入到映射表(Album_Artiest)中,这样可以使用普通的sql语句或创建一个tableadapter / dataset类似于您之前使用的表wizzard的艺术家。然后将数据插入数据表并保存。它应该与db同步。
You want to fill the DropDown for the Artiest from the Artiest DataTable. To Do so set the Artist DataTable as DataSource to the DropDown.
To Save the data you have to insert them into the mapping table (Album_Artiest) to do so you can either use plain sql statements or create a tableadapter/dataset similar to artist with the table wizzard you've used before. Then insert the data in the datatable and save it. It should be synced to db then.


这篇关于c#连接表插入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆