Dear all while I am trying to create database..I got these error
An attempt to attach an auto-named database for file C:\Documents and Settings\John Khalil\Desktop\ s.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
here the code to create the database
any idea?
An attempt to attach an auto-named database for file C:\Documents and Settings\John Khalil\Desktop\ s.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
here the code to create the database
Code:
SqlConnection temp = new SqlConnection(@"Data Source=.\SQLEXPRESS;Database = master;Integrated Security=True;Connect Timeout=30;User Instance=True");
string query = string.Format(" CREATE DATABASE "
+ name
+ " ON PRIMARY "
+ " (NAME = " + name +", "
+ " FILENAME = '" + path +"', "
+ "User ID = " + user
+ "Password =" +pass
+")");
SqlCommand command = new SqlCommand(query, temp);
Comment