MichelVanderbeke
Programmer
Hello everyone,
I have a problem attaching a database file to my SQLServer using Integrated Security.
Depending on where my .mdf and _log.LDF files are located it works or doesn’t work.
The connectionstring in the app.config-file of a C# project is:
providerName="System.Data.SqlClient"
connectionString="Data Source=PREDATORG9-793;
AttachDbFilename = D:\_Michel Vanderbeke\Documents\Visual Studio 2017\Projects\Michels gegevens\Michels gegevens\Gegevens\Michels gegevens.mdf;
Integrated Security=true;
Connect Timeout = 30"
This way the program runs fine.
When I move the .mdf file to another location and adjust the connectionstring to:
providerName="System.Data.SqlClient"
connectionString="Data Source=PREDATORG9-793;
AttachDbFilename = C:\Test_C\Michels gegevens.mdf;
Integrated Security=true;
Connect Timeout = 30"
I get an error message:
{"Unable to open the physical file \"C:\\Test_C\\Michels gegevens.mdf\". Operating system error 5: \"5(Access denied.)\".\r\nAn attempt to attach an auto-named database for file C:\\Test_C\\Michels gegevens.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."}
Can someone help me with this error? Why can’t I put the database-files on a different location? The only difference between the two connection strings is the map where the database-files are.
Many thanks and greetings,
Michel
I have a problem attaching a database file to my SQLServer using Integrated Security.
Depending on where my .mdf and _log.LDF files are located it works or doesn’t work.
The connectionstring in the app.config-file of a C# project is:
providerName="System.Data.SqlClient"
connectionString="Data Source=PREDATORG9-793;
AttachDbFilename = D:\_Michel Vanderbeke\Documents\Visual Studio 2017\Projects\Michels gegevens\Michels gegevens\Gegevens\Michels gegevens.mdf;
Integrated Security=true;
Connect Timeout = 30"
This way the program runs fine.
When I move the .mdf file to another location and adjust the connectionstring to:
providerName="System.Data.SqlClient"
connectionString="Data Source=PREDATORG9-793;
AttachDbFilename = C:\Test_C\Michels gegevens.mdf;
Integrated Security=true;
Connect Timeout = 30"
I get an error message:
{"Unable to open the physical file \"C:\\Test_C\\Michels gegevens.mdf\". Operating system error 5: \"5(Access denied.)\".\r\nAn attempt to attach an auto-named database for file C:\\Test_C\\Michels gegevens.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."}
Can someone help me with this error? Why can’t I put the database-files on a different location? The only difference between the two connection strings is the map where the database-files are.
Many thanks and greetings,
Michel