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

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
Dov_BAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Luis PérezSoftware Architect in .NetCommented:
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.
0
Jorge PaulinoIT Pro/DeveloperCommented:
In My Project - Publish Tab - Application Files do you have the database as data file or included ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dov_BAuthor Commented:
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
0
Jorge PaulinoIT Pro/DeveloperCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.