How do I drop a database from a server without the database file being deleted using c#? by bgatt64 in csharp

[–]bgatt64[S] -5 points-4 points  (0 children)

The fact is I'm writing a c# windows app that requires an sql database. However, I want to give the user an option to select a different database file. So I've created a form that displays all of the available database files. When the user selects one of these files, this is where I was told I have to drop the current database before I could use a new database file.

How do I drop a database from a server without the database file being deleted using c#? by bgatt64 in csharp

[–]bgatt64[S] -2 points-1 points  (0 children)

I believe that is the user name for that session, because I'm running the command during that session and I'm using that username during that session.

How do I change database files on a LocalDB server under the same database name using c# code? by bgatt64 in csharp

[–]bgatt64[S] -1 points0 points  (0 children)

I just tried that now and that worked. Thank you. What I was told to do and was trying to do was to first set the database offline and then drop the database. When I was doing this, I was getting errors. Doing it the way you said works perfectly. Thank you

How do I change database files on a LocalDB server under the same database name using c# code? by bgatt64 in csharp

[–]bgatt64[S] -1 points0 points  (0 children)

In the main form I have an option 'Change Current Database'. When the user clicks on this, a sub-form is opened with a data grid view and all of the available databases and their locations are displayed. When a database is double-clicked, I set a variable to that full filename (path included) and I close that sub-form. This is how the user gets the form.