如何在C#中做到这一点 [英] how to make this in c#
问题描述
亲爱的先生
现在,如果我有带有以下数据的表
CarID CarName
100宝马
200蓝瑟
300 JEEP
... etc
我还有一张桌子2
PriceID CarID价格日期
汽车公司
现在我想要一个具有以下形状的datagridview(不会输入CarID和CarName,它将以某种方式从table1填充)
CarID CarName PriceID价格日期
现在我希望能够在datagrid中输入新数据
例如
CarID CarName PriceID价格日期
100 BMW autogen 500K $ 2011年1月6日
200 Lancer"100k $ 2/6/2011
300吉普车"200K $ 2011年10月6日
100宝马autogen 510K $ 2011/1/7
200 Lancer"130k $ 2011年7月20日
300 Jeep"240K $ 2011/7/30
因此保存表之后,应该完全不更改,但应该更新table2
PriceID CarID价格日期
autogen 100 500K $ 2011年1月6日
"200 100k $ 2/6/2011
"300 200K $ 10/6/2011
"100 510K $ 2011/1/7
"200 130k $ 2011年7月20日
"300 240K $ 2011/7/30
那我该怎么做呢?
我不需要完整的代码,我只需要一些提示
我不知道如何从两个表中读取datagridview,但仅更新其中一个表
我知道如何使用select join
从两个表中读取数据网格
但是当它更新时如何使其更新其中之一
感谢
Dear Sir
now if i have table1 with following data
CarID CarName
100 BMW
200 Lancer
300 JEEP
...etc
and i have another table2
PriceID CarID Price Date
auto inc
now i want a datagridview with following shape (CarID & CarName will not be entered it will filled from table1 by somehow)
CarID CarName PriceID Price Date
now i want to be able to enter new data in the datagrid
so for example
CarID CarName PriceID Price Date
100 BMW autogen 500K$ 1/6/2011
200 Lancer " 100k$ 2/6/2011
300 Jeep " 200K$ 10/6/2011
100 BMW autogen 510K$ 1/7/2011
200 Lancer " 130k$ 20/7/2011
300 Jeep " 240K$ 30/7/2011
so after saving tabel should no change at all but table2 should be updated
PriceID CarID Price Date
autogen 100 500K$ 1/6/2011
" 200 100k$ 2/6/2011
" 300 200K$ 10/6/2011
" 100 510K$ 1/7/2011
" 200 130k$ 20/7/2011
" 300 240K$ 30/7/2011
so how can i made that??
i don''t want a complete code i want just some tips
i don''t know how to make the datagridview read from two tables but update only one of them
i know how to make the datagrid read from two tables using select join
but when it update how to make it update one of them
thanks
推荐答案
1/6/2011
200 Lancer"100k
1/6/2011
200 Lancer " 100k
2/6/2011
300吉普车"200K
2/6/2011
300 Jeep " 200K
2011/10/6
100宝马autogen 510K
10/6/2011
100 BMW autogen 510K
这篇关于如何在C#中做到这一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!