Serverless Database in C#

2020-06-23 08:23发布

Complete newbie question here: I'm just playing with C# for the first time and want to make a Windows Forms application which stores some info in a database structure, but obviously don't want to require something like MySQL to be installed on each client's computer. How do I go about this?

标签: c# database
9条回答
霸刀☆藐视天下
2楼-- · 2020-06-23 09:00

You could write your data to XML files, or you could take a look at the Sql Server Compact Edition.

You could also work with objects and serialize/deserialize these to disk as binaries.

Of course the type of storage you choose depends a lot on the kind of data you're storing (and the volume of it).

查看更多
祖国的老花朵
3楼-- · 2020-06-23 09:01

Perhaps you could serialise a dataset and save it as XML. I'm a little confused why if you're playing around you would need to install MySQL on all client's computers. You could look at using SQL Express which is free perhaps?

Serialise Dataset:

http://blogs.msdn.com/yosit/archive/2003/07/10/9921.aspx http://msdn.microsoft.com/en-us/magazine/cc163911.aspx

查看更多
Melony?
4楼-- · 2020-06-23 09:04

The answer is Embedded Databases. You've got quite a large list of Embedded databases that you can use:

Commercial:

  1. VistaDB - This database is written completely in managed C#.

Open Source:

  1. Firebird - .NET Driver
  2. SQLite - .NET Driver
查看更多
聊天终结者
5楼-- · 2020-06-23 09:04

The Easiest way will be SQL Server Compact, Because it integrates directly into the Visual Studio IDE (I'm just hazarding the guess here that you use VS). Add the "Local Database", Create your tables and be sure to make your Table Adapter with Select, Update, Insert and Delete methods. If during Database Creation you called your Dataset "DS" you will be able to instantiate a Table Adapter Object from

DSTableAdapters 

Namespace, and Use GetData() or Fill() methods to retrieve your Data, and Insert(), Update() and Delete() to Manage it.

查看更多
姐就是有狂的资本
6楼-- · 2020-06-23 09:14

You use a database that doesn't require an install. There are a few out there - there's Microsoft SQL Server Compact, which frankly is badly named, as it won't support the more useful SQL functions like stored procedures, views and so on. There's also VistaDB which does support stored procs, but requires purchase if you want Visual Studio plugins.

查看更多
放荡不羁爱自由
7楼-- · 2020-06-23 09:15
登录 后发表回答