问题描述
我有3列:Id,国籍,宗教
当我保存国籍身份证件
例如:
1,American
2,Jordanian
然后我保存的宗教必须变成这样的
1,Christian ...
我尝试了什么:
当我点击按钮时,我将在网格视图中显示一个新行。 。
但是国籍的id与宗教不同,例如:
例如:
i存储id = 1,国籍=jordanian
id = 2,国籍=美国人
然后我想存储宗教信仰,id将成为(1)不是(3)
gridview必须显示如下:
id,nationality,religion
______________________________
1,jordanian
______________________________
2,美国
______________________________
1 ,, Christian
_______________________________
...我希望如此你明白我的意思
i have 3 columns : Id , nationality, religion
when i save the id for nationality
example :
1, American
2, Jordanian
then i saved religion must become like this
1,Christian...
What I have tried:
when i click the button new i will appear a new row in grid view ..
but the id for nationality differ from the religion ,
for example :
i stored id =1, nationality="jordanian"
id=2, nationality=" American"
then i wanna to store religion , the id will become (1) not (3)
the gridview must display like this :
id , nationality, religion
______________________________
1 ,jordanian
______________________________
2 ,American
______________________________
1 , ,Christian
_______________________________
...I hope that you understand what I mean
推荐答案
Id Name
1 American
2 Jordanian
宗教
Religions
Id Name
1 Christian
2 Jedi
3 Pastafarian
然后你有第三张桌子(你是用于提供链接:
用户
You then have a third table (which you use to provide the links:
Users
Id Nationality Religion Name
1 1 1 Joe
2 1 2 Luke
3 2 1 Amir
4 ...
这是因为你需要 [],以便以后可以有效地获取和更新数据。
如果您使用VB中的类来表示这一点,那么您将创建三个类,并使用第三个类中的引用将您链接到国籍和宗教的实际数据实例。如果您在国籍和宗教类中覆盖ToString,DGV将自动为您显示正确的数据。
This is because you need to normalize the databases[^], so that later you can fetch and update the data efficiently.
If you are using classes in VB to represent this, then you would create three classes, and use references in the third to link you to the actual data instances for Nationality and Religion. If you override ToString in the Nationality and Religion classes, the DGV will display the right data for you automatically.
这篇关于我怎样才能保存身份,国籍,宗教专栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!