Click here to Skip to main content
15,878,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm stuck while developing a small desktop Project Management application in C# (VS2019).

My solution would have two projects in it:

- a library project (models, classes, XSD datasets...), and the
- application project (forms, other classes closely related to the application)

In the application project I'd use data objects (i.e. datagridviews, bindingnavbars, and so on) for the BL implementation.

I'm already developing a similar project based on SQL Server DB, but this small project should go serverless. So I thought that an MDF file could meet my needs.

When I run the published project, things go awry: the connection string is pointing the MDF in an absolute path within the vs project folder.


1. is using XSD to access MDF actually a good choice?
2. can I have the program create a MDF file in runtime (in a folder of user's choice)?
3. can the connection string be edited in runtime in order to "switch" database as needed?

What I have tried:

I added a new component > Data > MDF in the library project and I started adding tables in the MDF through the Server Panel. Then I added tableadapters in the dataset (draggin the tables directly from the Server Panel), made the databindings for the CRUD operations in the application project's forms... everything just works while debugging withing the IDE.
Updated 4-Dec-21 12:58pm

The way I do it s probably overkill for your application, but ... Instance Storage - A Simple Way to Share Configuration Data among Applications[^]
It's also intended for SQL Server, so the examples are for that - but the principle is identical for Access MDF files (or ACCDB), just the actual base connection string chnages. If nothing else, it'll give you the idea.
Share this answer
I think XSD was before SQL CE, which was before SQLite, which was before EF (entity framework). You may want to consider EF with SQLite (no "server").

Getting Started - EF Core | Microsoft Docs[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900