C# (Visual studio):数据库、数据集、绑定源之间的关联
我刚刚通过 Visual Studio 2008 学习 C#?
我想知道数据库、数据集和绑定源之间到底有什么关联?
还有,表适配器的作用是什么?
I am just learning C# through Visual Studio 2008?
I was wondering what exactly is the correlation between dabases, datasets and binding sources?
As well, what is the function of the table adapter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在超高级别:
数据库——存储原始数据
DataSet——一个.NET对象,可用于读取、插入、更新和删除数据。数据库
BindingSource —— 一个.NET 对象,可用于控件的数据绑定。 BindingSource 可以指向 DataSet,在这种情况下,控件将显示和编辑该数据
TableAdapter -- 将数据从数据库表映射到 DataSet
所有这些内容还有很多内容,了解 ADO.NET 的架构方式可能需要一些时间。 祝你好运!
At a super high level:
Database -- stores raw data
DataSet -- a .NET object that can be used to read, insert, update and delete data in a database
BindingSource -- a .NET object that can be used for Data Binding for a control. The BindingSource could point to a DataSet, in which case the control would display and edit that data
TableAdapter -- Maps data from a database table into a DataSet
There is a lot more to all of these, and understanding the way ADO.NET is architected can take a bit of time. Good luck!
DataSet 通常用于在内存中保存数据库的结果,即它包含一个DataTable 对象。 DataSet 和DataTable 对象本身独立于数据库,因此结果不必来自数据库。 DataSet 可以包含多个DataTable,您甚至可以定义它们之间的关系。 它就像内存中的一个迷你数据库。
绑定源是可以提供具有属性的对象列表的任何对象。 DataSet 或 DataTable 可以做到这一点,但它基本上可以是包含具有属性的对象的任何类型的列表。
TableAdapter 用于从 Command 对象提供的 DataReader 中读取数据,并将数据放入 DataTable 对象中。
A DataSet is usually used to hold a result from the database in memory, i.e. it contains a DataTable object. The DataSet and DataTable objects themselfs are independent of the database, so the result doesn't have to come from a database. The DataSet can contain several DataTables, and you can even define relations between them. It's like a mini database in memory.
A binding source is any object that can provide a list of objects with properties. A DataSet or a DataTable can do that, but it could basically be any kind of list containing objects that has properties.
A TableAdapter is used to read data from a DataReader provided by a Command object, and put the data in a DataTable object.
数据集是数据库的(部分)内存中表示。 数据库中的表或视图在数据集中表示为数据表。 数据适配器是数据库和数据集之间的链接。 一旦适配器将数据加载到数据集中,就释放与数据集的物理连接。 这就是为什么它被称为断开连接的数据模型。
The dataset is a (partial) in-memory representation of a database. Tables or Views in the datatbase are represented as datatables in a dataset. The dataadapter is the link between the database and the dataset. Once the adapter has loaded the data into the dataset, the physical connection to the dataset is disposed. This is why it's called a disconnected data-model.