I deleted manually sql database file(myDB.mdf and myDB_log.ldf) When I want to create database with same name (myDB) I get the following error message.
System.Data.SqlClient.SqlException (0x80131904):Database 'myDB' already exists. Choose a different database name.
my code:
String str;
SqlConnection Conn = new SqlConnection("Server=.\\SQLEXPRESS;Integrated security=true;User Instance=True;database=master");
str = "CREATE DATABASE myDB " +
"ON PRIMARY " + "( NAME = N'myDB', FILENAME = N'" + Application.StartupPath + "\\myDB.mdf' , SIZE = 5120KB , FILEGROWTH = 1024KB )" +
"LOG ON" + "( NAME = N'myDB_log', FILENAME = N'" + Application.StartupPath + "\\myDB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)";
SqlCommand Command = new SqlCommand(str, Conn);
how fix this by c# script?