我应该在Windows窗体应用程序中使用什么类型的数据库 [英] What type of database should I use in Windows form application

查看:257
本文介绍了我应该在Windows窗体应用程序中使用什么类型的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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


由于您主要关注的不是创建数据库,我建议您将数据保存在文件中。否则,您将花费大量时间学习SQL的语法以及数据库结构和管理。 (假设您将使用本地PC而不是服务器上托管的数据库)



在这种情况下,我认为XML将是一个不错的选择,因为您可以使用 DataTable DataSet 将Windows窗体控件绑定到。有一些方法可用于从磁盘读取和写入XML数据。

此外,如果您稍后改变主意并决定将数据存储在数据库中,代码中的更改将会更改不是很大。



您仍需要在数据集中设计表结构,但Visual Studio对此非常有用。 在Visual Studio中使用数据集 [ ^ ]



由于建议不要将 DataSet 直接绑定到Form Controls,您还需要查看绑定源类 [ ^ ]。



*首先找到您将使用的不同数据变量并创建数据结构。

*设计如何在表单中显示数据。

*将数据和视图连接在一起。


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.

解决方案

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[^].

—SA


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.


这篇关于我应该在Windows窗体应用程序中使用什么类型的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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