after I publish my application and run it it cannot find my database file

Posted on 2008-11-11
Medium Priority
Last Modified: 2012-05-05
when I test it from the code that application connects to the database with :
constring = "Data Source=" & My.Application.Info.DirectoryPath & "\Database1.sdf;Persist Security Info=False;"
but when I publish it and try to run the published version I get an error and it says to check the path
Question by:Dov_B
  • 2
LVL 25

Expert Comment

by:Luis Pérez
ID: 22934934
First, check that the database file is present at run-time.
Second, try Application.StartupPath instead of My.Application.Info.DirectoryPath.

If nothing of this works, please post the complete code of the exception thrown.
LVL 48

Accepted Solution

jpaulino earned 2000 total points
ID: 22934967
In My Project - Publish Tab - Application Files do you have the database as data file or included ?

Author Comment

ID: 22935043
may you be blessed thankyou thankyou thankyou
it was set as auto I changed it to included and then it worked by the way why was that necessary
LVL 48

Expert Comment

ID: 22935209
You have to tell the publish process that you will use that. and that will be published.
Example, you sometimes work with local SQL databases but then when you deploy your application the database is running on the server. You don't need to include that on your project! If you really want you have to tell that.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question