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

Posted on 2008-11-11
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
    LVL 25

    Expert Comment

    by:Luis Pérez
    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

    In My Project - Publish Tab - Application Files do you have the database as data file or included ?

    Author Comment

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now