简体   繁体   中英

Windows Forms Application Database

Is it possible to have a build-in database in a windows forms application? I know you can connect to a database to the 'outside', but you require an internet connection for that. I pretty much just want to have a database that is accessible without internet

Anyone know how to do this?

There are a number of databases you can use. I'm not sure why you think accessing a database requires internet access. Here are some databases that you can use that don't require internet access. The only ones I can think of that require internet access are cloud based databases like SQL Azure (and they are more designed to be used from an application that is also running in the cloud)

  • SQL Server
  • SQL Server Express (also has some sort of file mode)
  • SQL Server Compact (has some limitations I didn't expect over regular SQL Server like no schema support)
  • SQLite (file based)
  • Vista DB (strong compatibility with SQL Server)
  • MySQL
  • Oracle
  • RavenDB

I suspect that if you want it "built in" to your application then something along the lines of VistaDB or SQLite may be more to your liking as they only require the addition of the relevant assemblies and database file for your application to be able to use the database.

I would recommend you use SQLite as it is very lightweight and can be embedded in almost any application. By the way, it is the default database engine for Android applications.

The easiest way to use it is through ServiceStack OrmLite . It is a free ORM (v3 only, v4 is not). You can get it from NuGet using the following command in the package manager console:

PM> Install-Package ServiceStack.OrmLite.Sqlite32 -Version 3.9.71

还有Microsoft的SQL Server Compact: http//msdn.microsoft.com/zh-cn/data/ff687142.aspx

You can run pretty much any DB locally without requiring internet connection. You need to locally run the DB and refer to localhost (127.0.0.1) when referring to the connection string. Details of course change according to the DB you choose to adopt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM