An Attempt to attach an auto-named database Error

前端 未结 6 793
名媛妹妹
名媛妹妹 2020-12-03 21:48

\"An attempt to attach an auto-named database for file C:\\Users\\John\\documents\\visual studio 2010\\Projects\\PAS\\PAS\\bin\\Debug//PatAddSys.mdf failed. A database with

6条回答
  •  无人及你
    2020-12-03 22:27

    Actually I've crashed to this problem but I handled it easily. if your connection string is

     connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;"
    

    you need to make your own localDB. first go to command prompt than write

    sqllocaldb create MyDatabase
    

    than start your database

    sqllocaldb start MyDatabase
    

    than return to VS and change your connection string to

    connectionString="Data Source=(LocalDB)\MyDatabase;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;"
    

提交回复
热议问题