使用C#、、、 [英] Rerieve data in Ms-Access Database using C#,,,,

查看:60
本文介绍了使用C#、、、的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我正在M-Acess中创建一个表并以C#Windows形式连接,
问题我有一个表,表中没有几列,但是一个列名是Department,并且我正在IT中分配一个离场表格,而这些人部门是IT,他的名字出现在Form中...

My problem is,, I m creating a table in Ms-Acess And Connect in C# Windows Form,,,
Problem I have a one tabel,, table have few column ,, but one Column Name is Department,, And i am assigning a depart form some people in IT,, And those person department is IT his name Appear in Form...

推荐答案

首先,没有一个表:至少有两个表:
Firstly, don''t have one table: have at least two:
Employees
Int             Id
NVARCHAR        Name
Int             DepartmentId


Departments
Int             Id
NVARCHAR        Name


这样,您只记录一次信息:每个员工都有对部门的引用,而无需每次都使用实际姓名. (Id不必是Ints,也可以很容易地成为Guid)

其次,您的问题是什么?


This way you are only recording information once: each employee has a reference to the department, without needing the actual name each time. (The Ids don''t need to be Ints, they could as easily be Guids)

Secondly, what is your problem?


请参阅此代码项目文章.
用于从DataBase和使用反射将DataTable保存到数据库中 [Order 视为部门,将Order details视为该部门中的人员.
我认为这可能会有所帮助.
Please see this Code Project article.
General purpose class to fill DataTable(s) from DataBase and to save DataTable(s) to DataBase using reflection[^]
There is a sample with MS Access database and C# in this article. When you run the sample program, see the second tab page (i.e. Orders and Order details) in which, if an order is selected the corresponding order details are shown in the bottom table (DataGridView). Think of Order as the department and Order details as the persons in that department.
I think it may be helpful.


这篇关于使用C#、、、的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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