Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating SQL Server Database files on the fly with C#

Tags:

c#

sql-server

Is it possible to create database files that are independent from any SQL Server engine on the fly? The thing is that we want to create one database file per user in our application, and we want that database to be stored in the user's directory but we don't want to connect to it through SQL Server. Prety much like an sdf file, but instead of App specific, User specific.

So what we want to do is that every time a user is created in the app, generate their folder, and generate the database schema, which will be populated later.

like image 896
Carlo Avatar asked Jan 01 '26 01:01

Carlo


2 Answers

Sounds like you're looking for SQL Server Compact. You can create any number of these databases at runtime and place them anywhere you want.

like image 157
Mauricio Scheffer Avatar answered Jan 02 '26 14:01

Mauricio Scheffer


Sounds like you really want a combo of "Access" and the Jet engine. It meets the database in a single file requirement and is reasonably performant for single user access.

Another possibility would sqlite, which is IMHO a better database but support for C# seems immature.

like image 26
James Anderson Avatar answered Jan 02 '26 16:01

James Anderson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!