createing database problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • little83
    New Member
    • Feb 2009
    • 26

    createing database problem

    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
    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);
    any idea?
    Last edited by pbmods; Mar 9 '09, 11:21 PM. Reason: Added CODE tags.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Well, is it already existing?

    -- CK

    Comment

    Working...