How to create database programmatically in visual studio c#

I used to create the MDF database manually in Visual Studio, now I want to try create the database programmatically inside the program.

The first useful article I found was from microsoft, but without success. There were 2 issues here:

1. the server name – in the example, they use “server = localhost”, it should be changed to “server = .\\SQLEXPRESS”

2. “create file encountered operating system error 5(access is denied.)” – the possible solution may be this

more info:

Leave a Reply

Your email address will not be published. Required fields are marked *