Detach database that deleted in SqlExpress

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajjadlove
    New Member
    • Apr 2009
    • 19

    Detach database that deleted in SqlExpress

    Hi
    I attached a database to SqlExpress.then moved the project to another place and deleted the last project(with it's mdf file).now, i can't attach database in new address to SqlExpress.
    when i use from following connection:
    Code:
    Data Source=.\\SQLEXPRESS; AttachDBFileName=|datadirectory|dbName.mdf; Initial Catalog=dbName; Integrated Security=True;User Instance=true
    it thrown an exception: 'Database already exsist'
    and when i change to following Connection
    Code:
    Source=.\\SQLEXPRESS; Initial Catalog=dbName; Integrated Security=True;User Instance=true
    it thrown an exception too:'Can not open database that requested to login'

    I'm very confused...
    How can i detach last database from SqlExpress?
  • sajjadlove
    New Member
    • Apr 2009
    • 19

    #2
    I found a solution for this problem.i created a folder like last project folder and copied the database in it.it worked and data displayed, but i can't detach it...

    when i use from below query:
    Code:
    EXEC sp_detach_db 'D:\last folder\dbName.mdf','true'
    give me an error that this database doesn't exists, whereas when i used from following ConnectionStrin g, data displayed:
    Code:
    Data Source=.\\SQLEXPRESS; Initial Catalog=dbName; Integrated Security=True;User Instance=true
    would you please help me about this problem???!

    Comment

    Working...