我应该在Windows窗体应用程序中使用什么类型的数据库 [英] What type of database should I use in Windows form application
问题描述
我有一个C#任务,我必须为家具进出口公司设计一个库存软件。我的软件设计(类/继承)是将要评估的主要内容。但是要运行应用程序,我必须在某处保存虚拟值(客户,项目和事务)。我想将它们保存在文本文件中。如果你们人们可以建议我这样简单而且更好的方法,我将非常感激。因为我不想在它不重要的时候花太多时间。我正在使用Windows窗体应用程序。
你真的需要接受关注点分离的想法。System.Windows.Forms
与数据库无关,因此您可以将其与您选择的数据库技术相结合,具体取决于您希望实现的目标。首先,请查看以下列表:
https://en.wikipedia.org/wiki/Comparison_of_database_tools [ ^ ],
https://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems [ ^ ],
https://en.wikipedia.org/wiki/Comparison_of_object_database_management_systems [ ^ ]。
-SA
I have a C# assignment where I have to design an inventory software for furniture import and export company. My software design(classes/inheritance) is the main thing that will be evaluated. But to run the application I have to save dummy values somewhere(Customers, Items and transactions). I was thinking to save them in text files. I would be very thankful if you people can suggest me simple and better way to do that. Because I do not want to spend much time on it when it is not important. I am using windows form application. 这篇关于我应该在Windows窗体应用程序中使用什么类型的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
在这种情况下,我认为XML将是一个不错的选择,因为您可以使用 DataTable
和 DataSet
将Windows窗体控件绑定到。有一些方法可用于从磁盘读取和写入XML数据。
此外,如果您稍后改变主意并决定将数据存储在数据库中,代码中的更改将会更改不是很大。
您仍需要在数据集中设计表结构,但Visual Studio对此非常有用。 在Visual Studio中使用数据集 [ ^ ]
由于建议不要将 DataSet
直接绑定到Form Controls,您还需要查看绑定源类 [ ^ ]。
*首先找到您将使用的不同数据变量并创建数据结构。
*设计如何在表单中显示数据。
*将数据和视图连接在一起。
You really, really need to embrace the idea of separation of concerns.
System.Windows.Forms
has nothing to do with databases, so you can combine it with database technology of your choice, depending on what you want to achieve. For starters, please review these lists:
https://en.wikipedia.org/wiki/Comparison_of_database_tools[^],
https://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems[^],
https://en.wikipedia.org/wiki/Comparison_of_object_database_management_systems[^].
As your main concern is not to create a database, I would recommend to save your data in a file. Otherwise you will end up spending a lot of time learning the syntax of SQL and also database structure and administration. (Assuming you will use your local PC and not a database hosted on a server)
In this case I think XML would be a good choice, because you can use DataTable
and DataSet
to bind your windows form controls to. There are methods already available to read and write XML data to/from disk.
Also, if you would change your mind later on and decide to store the data in a database, the changes in your code will not be very big.
You still need to design a table structure in your data set, but Visual Studio is pretty helpful with that. Here is a good starting point Working with Datasets in Visual Studio[^]
As it is recommended not to bind a DataSet
directly to Form Controls, you also need to look into the BindingSource class[^].
* So start with finding the different data variables you will use and create your data structure.
* Make a design for how to present the data in the form.
* Connect the data and the view together.