AttachDbFileName in Connection String in Vb.Net code gives errors.

  • While using AttachDbFileName in the connection string to attach database to localdb,The following error occurs

    Error: The logical database file 'Common WM_log' cannot be found. Specify the full path for the file.
    An attempt to attach an auto-named database for file C:\Users\source\repos\WindowsApp20\WindowsApp20\bin\Debug\common.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

    Here is the connection String that we are currently using.

     Private connectionString As String = "Data Source=(localdb)\v11.0;AttachDbFileName=E:\common WM.mdf;Integrated Security =true;"

    Please note that the mdf files were from SQL Server 2008

    Tried placing the mdf ldf files in application path in C drive also. It did not work.


    When Create database ..For attach or sp_attach_db  is used for same mdf file and localdb , it works .

    Why is it not working in AttachDbFileName ?


  • ty with the path within double quotes - note that I didn't escape them below - but you will need to do that for sure (possibly a double double quote)

    Private connectionString As String = "Data Source=(localdb)\v11.0;AttachDbFileName="E:\common WM.mdf";Integrated Security =true;"
  • I have already tried this , does not work . Same error repeats.

  • Can this help you out?

    "Troubleshoot SQL Server 2012 Express LocalDB"


    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply