.NET Window Forms local database

后端 未结 3 625
粉色の甜心
粉色の甜心 2021-01-26 00:03

I just started writing a Windows Forms Application and I\'d like to store data in a Database but not in an actual DB Server.. something like SQLite (local, server independent).

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 00:33

    If you don't have to save a huge amount of data you can use XML or even JSON. With JSON.NET you can serialize objects and write them to a text file, then read json file and get your data back.

    // define you data type
    class MyData
    {
       ...
    }
    
    // using MyData
    string jsonString= myDaJsonConvert.SerializeObject>(data);
    List data = myDaJsonConvert.DeserializeObject>(jsonString);
    

    EDIT 1:

    Even if its System.Data.SQlite assembly is outdated this legacy setup file contains a "Designer" component for ADO.NET 2.0 which might simplify a lot the Dataset creation routine. Please remember to update SQlite libraries from this site later.

提交回复
热议问题