Hi All,
I am building a VS2005 Database project, and I have recently discovered the use of ClickOnce apps. However I have a problem that I don't understand.
I have a SQL Server 2005 DB, marked "SQL Server 2005 Express" as a prerequisite, so that's OK.
I had trouble with the connection string, but I found in another thread that ClickOnce copies the MDF file to a Data folder, and that the connectionstring can be made as follows:
Initial Catalog=<appname>; Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\<dbname>.mdf;Integrated Security=True
So that should be OK too. When I deploy it, the app is installed in C:\Documents and Settings\Wouter\Local Settings\Apps\2.0\<something>\<something else>\...
So far so well, then when the app is ran, and the connection is opened, i get the following error:
Directory lookup for the file "Settings\Wouter\Local Settings\Apps\2.0\Data\<something>\<something else>\...\<appname>.mdf" failed with the operating system error 5(Access is denied.)."
Could not attach file '........... <again the same>' as database '<dbname>'.
This led to much frustration, searched all over the net, and nobody seems to have had the same error.
In a bright moment I set the Permissions for the SQL Server User account ('BLUEBIRD-X2\SQLServer2005MSSQLUser$BLUEBIRD-X2$SQLEXPRESS' to be precise) to Full on the Local Settings folder (right click > properties > security), and then IT WORKED.
Now the question: WHY is this necessary? I suppose a ClickOnce app has full security permissions on its install directory?
I cannot expect all end users to set the permissions on the Local Settings folder, especially because it is hidden.
How can I make my database connect to this *hidden & secured* path, that i cannot change due to ClickOnce default install path?
If i remove the Security Permissions for the SQL Server User account, after the DB has been attached to SQL sever, then connecting is again no problem.
Any answer is welcome.
Thank you,
Wouter
PS. I am not using < > in my db name
, just indicating variables