How can I have my C# application use a single FILE database?
Right now I have my program running on my SQLExpress database. But what I'd really like is for my program to run on any machine as long as A DATABASE FILE is in the same folder. How can I accomplish this?
Firs things's first: How would my connection string be if I were connecting to a FILE DATABASE?
Second: How do I create a开发者_如何转开发 single file database from an existing SQLExpress database?
Just like stated above, SQL Server is a server-class database engine. There are some smaller solutions called 'in memory databses' (so they do rely only on a database file) that you may want to use:
- SQLite
- Microsoft SQL Server Compact
Which one to choose? Well, it may be easier for you to transform your SQL Server data int SQL Server Compact than to SQLite. Be aware, that those databases are quite simple, and some things may be missing (stored procedures, funcions... - just take a look at documentation and specification).
You can use AttachDBFilename and UserInstance=True.
you could use sqlite3 (file DB)
Sql Server is a server-class engine. If you want it to run on any machine you need to choose an in-process database engine like Sql Server compact edition, sqlite, or even access, where you can easily distribute the engine with your app.
精彩评论