Leedo

Hello,

I am having troubles understanding the dynamics of publishing or creating a setup for a database project. I have a VB Windows forms database application which contains a database in it. I am using it in my development environment with no problems. However, when I publich it using click once or adding a setup application, I can never get the application to work correctly in the target machine. It seems that the application can't find the MDF file or attach the database.


What is the best scenario in this situation Thanks

PS: My connection strings includes the "AttachDbFilename" directive.



Re: ClickOnce and Setup & Deployment Projects Database Project Setup

Yu Guo C MSFT

Hi, Leedo,

Based on my understanding, you want to know how to deploy your MDF file by ClickOnce and Setup Project, don't you

I think your problem may be caused by the MDF file not copied to the output folder.
You should right click the MDF file in your Solution Explorer, and choose Properties.
In the Propties window, you should set "Copy to output Directory" to "Copy always".

Besides, you should not change the auto generated connection string, you can find it in the Setting tab of your Project Properties window, and it should look like
Code Block

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True


The |DataDirectory| is important for ClickOnce deployment, it helps the application to find the Data Directory.
http://msdn2.microsoft.com/en-us/library/d8saf4wy.aspx

Don't forget to add the MDF file into Application Files in Publish Tab, and the Sql Server Express 2005 is also needed in the Prerequisites.

After that, I think you should be able to deploy your application without any problem.

Hope this helps.
Regards





Re: ClickOnce and Setup & Deployment Projects Database Project Setup

HussainAkbar

This is precisely what I am attempting to do. And so far failing.

Question: Where should I put my MDF If I add it to "User's Application Data" special folder, on the target machine it gets installed to c:\Docs and Setting\User\Application Data. Which isn't right, is it It should go to C:\Docs and Settings\All Users\App Data which is accessible by everyone. However, there's no option for All Users App Data special folder. Should I add it Common Files I also get strange errors when I try to run the app on the target. It fails to start completely.

Is there a walkthru that explains how to do this Preferably, a complete one showing how to make an app from scratch and make the setup for it.

TIA





Re: ClickOnce and Setup & Deployment Projects Database Project Setup

Bogdan Maxim