Reputation: 43
i am making a WPF program. This program has a database and dataset. The software is working great on the computer i made the program on. Today I tested the software on another PC. But it was not working because it couldn't find the SQL server.
So that is a problem. I thought it was local so I can use it everywhere but that is not the case.
What i want is a database that is portable, so can be used on every computer and it works offline. I don't know where to start and hope someone can give me some tips
Upvotes: 3
Views: 1294
Reputation: 12276
Another option to consider is not to use a database at all. Serialisation and deserialization objects to files is often way faster than any of the database options.
Serialisation is best suited when your data is not hugely dynamic or you're saving multiple relatively discrete chunks. I coverted an app from win ce to serialisation a while ago. It significantly speeded up as a result. Made much more of a difference than I expected.
And of course you can use linq to xml to query filter sort etc.
You can mix this with a message queue such as ms mq and persist the dynamic part of your data you're capturing to disk in a queue. Consider a salesman with an occasionally connected app on a laptop. They could load fairly static data such as product options and costs as xml. Deserialise that in the app so they can put a quote together. They then need to persist the quotes. You could just serialise each quote as a separate file and it'd fly. Or you could persist them using message queue. Have a windows service which looks for when the laptop connects to wi fi. When connected it gets each of the quotes off the queue and sends them to head office by calling a web service.
Upvotes: 1
Reputation: 14233
You can copy an MDF file around using SQL Server LocalDB (formerly known as CE - Compact Edition).
SQLite is a good option, too. That's what it was made for. Libraries can be found on their homepage here or on Nuget here.
A connection string for the MDF option would look like this:
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
More connection strings can be found here:
Upvotes: 1