C#:使用数据库还是excel还是XML? [英] C#:using a database or excel or XML?

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

问题描述

大家好,



我在编程方面很陌生,我想听听一些想法。目前在工作中,我们正在使用excel电子表格,经过一些计算,移动和替换后,我们提供了新的生成电子表格。



我想更改应用程序进入C#应用程序(wpf)。对于功能我不认为会有更多的额外内容,它只是wpf的一些练习开始。因为将来我会用wpf更多地工作。



i现在正在考虑:我应该使用数据库(access或oracle)还是继续编程excel但是使用C#。



另一个想法是将数据保存在xml文件中,但将其从C#中拉入数据表并在那里做你的魔法。 />


最后,我会很乐意处理大量数据(excel中最多20k行)并快速处理。



我很好奇你的想法。一些专业和反对者会很好。



非常感谢。



J



我尝试了什么:



我认为使用xml文件相当不错。



您可以将无限数据保存到txt文件。

很容易缩回到数据表。



我只是害怕数据表的局限性。



其他想法也欢迎!

解决方案

这是一个使用<$的简单Winforms示例c $ c> datagridview 包含XML数据:

XML to DataSet或GridView and back [ ^ ]



如果您不是一位经验丰富的程序员,我会避免使用WPF,我认为这比Winforms更难开始(但我当然习惯Winforms)。



这是一个使用<$ c $的更高级教程c> BindingSource (推荐!):

详细的数据绑定教程 [ ^ ]



XML易于入手,如果性能太低,您可以随时调整代码以供数据库使用。

首先,不要使用Excel,除非特别要求使用Excel,因为用户工作流程的一部分已经在Excel中且无法更改。即使是这种情况,请确保您尝试了所有方法来摆脱Excel。在编程中使用MS Office是低技术的一个重要标志;与此同时,它并不容易,相当浪费。我已经面临人们假装Excel(电子表格,首先)是一个数据库系统。最好不要买这个谬论。它可以作为数据库连接,但为什么?



现在,XML和数据库之间有一个选择。如果是数据库,它是不同数据库系统之间的选择。以下是XML的标准:您可以使用XML并从中获得许多好处(简单,重量轻等),只有在您可以使用两个重要标准时:1)您的整个数据模型与单个集成在一起XML文件,没有外部XML文档(多文件但单文档XML会很好,比方说,你可以有单独的实体文件,doctype,共享XML模式),2)你确定所有的XML数据,整个过程,在解析时,总是很容易适应计算机RAM。如果不是这种情况,尤其是第二个标准,则XML不适合替换数据库。



XML的可接受替代方案是JSON。但请注意,Microsoft Data Contract与XML一起使用时,基本上比JSON灵活得多。使用XML,您的数据对象图本身可以是任意图形,但是使用JSON它只能是树,除非您通过引入一些特殊的结构关系来使用某些应用程序级别(非合同级别)的工作来解决问题键;那么你必须自己维护数据的完整性。请参阅:

使用数据合约

DataContractSerializer类(System.Runtime.Serialization)

DataContractJsonSerializer Class(System.Runtime.Serialization.Json)



怎么样选择数据库管理系统?在一个快速回答中,有太多因素需要认真讨论。您可以从查看以下列表和比较表开始:

关系数据库管理系统列表 - 维基百科,免费百科全书

关系数据库管理系统的比较 - 维基百科,免费的百科全书

对象 - 关系数据库管理系统的比较 - 维基百科,免费的百科全书



针对Microsoft产品的另一个警告:几乎在所有情况下,都不要选择Microsoft Access。它是专有的,不是开源的,不是免费的,不是轻量级但功能非常弱,只是不严肃。



-SA

Hi all,

i'm pretty new at programming and i want to hear some idea's. Currently at work, we're using an excel spreadsheet that gives us after some calculations and moving and replacing, the decired new generated spreadsheet.

I want to change the application into a C# application (wpf). For functionality i don't think there will be much extra's in it, it's just some start of practice in wpf. Because in the future i will be problably working more with wpf.

i was thinking now: should i work with a database (acces or oracle) or still program it out of excel but with C#.

An other idea was to save the data in an xml file but pull it into a datatable from C# and do your magic in there.

Eventually i would be nice to handle huge amounts of data (up to 20k rows in excel) and processing fast.

I'm curious about your idea's. Some Pro's and contra's would be nice.

much thanks appreciated.

J

What I have tried:

In my opinion is working with an xml file pretty good.

you can save unlimited data to a txt file.
easaly to retract to a datatable.

I'm only afraid of the limitations of a datatable.

Other idea's are also welcome!

解决方案

Here is a simple Winforms example of using a datagridview with XML data:
XML to DataSet or GridView and back[^]

If you are not an experienced programmer I would avoid WPF, in my opinion this is much harder to start with than Winforms (but I'm used to Winforms of course).

Here is a more advanced tutorial using BindingSource (recommended !):
A Detailed Data Binding Tutorial[^]

XML is easy to start with, if the performance is too low, you can always adapt the code for database use.


First of all, don't use Excel, unless Excel is specifically required because part of the user's workflow is already in Excel and it cannot be changed. Even if this is the case, make sure you tried all the ways to get rid of Excel. Using MS Office in programming in is a big sign of low-tech; at the same time, it's not easy, rather wasteful. I already faced people pretending that Excel (a spreadsheet, first of all) is a database system. Better don't buy this fallacy. It can be connected as a database though, but why?

Now, there is a choice between XML and database. If database, it's the choice between different database systems. Here is the criteria for XML: you can use XML and get a lot of benefits from it (simplicity, lighter weight, and so on), only if you can meed two important criteria: 1) your whole data model is integral withing a single XML file, with no external XML documents (multi-file but single-document XML would be perfectly fine, say, you can have separate entities files, doctype, shared XML schema), 2) you are sure that all the XML data, the whole thing, when parsed, will always easily fit in the computer RAM. If this is not the case, especially second criterion, XML is not a good candidate for the replacement of the database.

An acceptable alternative to XML is JSON. But note that the Microsoft Data Contract, when used with XML, is fundamentally much more flexible than JSON. With XML, your data object graph can natively be any arbitrary graph, but with JSON it can only be a tree, unless you use some application-level (not contract-level) work around the problem, by introducing some special "structural" relationship keys; then you would have to maintain the data integrity by yourself. Please see:
Using Data Contracts,
DataContractSerializer Class (System.Runtime.Serialization),
DataContractJsonSerializer Class (System.Runtime.Serialization.Json).

What about the choice of a database management system? There are too many factors to discuss them seriously in one Quick Answer. You can start with reviewing the following lists and comparison tables:
List of relational database management systems — Wikipedia, the free encyclopedia,
Comparison of relational database management systems — Wikipedia, the free encyclopedia,
Comparison of object-relational database management systems — Wikipedia, the free encyclopedia.

One more warning against Microsoft products: in almost all cases, don't chose Microsoft Access. It's proprietary, not open-source, not free of charge, not lightweight but extremely weak in features, just not serious.

—SA


这篇关于C#:使用数据库还是excel还是XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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