Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6691529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:45:44+00:00 2026-05-26T05:45:44+00:00

I have a Windows CE Form (NETCF 3.5) application that I’ve created via Visual

  • 0

I have a Windows CE Form (NETCF 3.5) application that I’ve created via Visual Studio 2008 (c#) – (However, the core of my question probably applies to normal Windows application, too).

The application implements a SQLite database that I’ve placed within the project – i.e. The database location is in the sub-directory within my project. So the connection string to the database looks something like:

@"Data Source = C:\src\myApp\data\mydb.s3db"

The connection to the database is fine and works.

After I created the database, I added a Data Set via VS2008’s “Data Source Configuration Wizard” (in VS2008, go to Data > Add New Data Source…). The wizard allows us to create a connection to an existing database and, then, choose tables from within that database that will be used in the Data Set that the wizard is about to create.

So the wizard does a fine job of creating the data set which allows us to program against it. The problem that I have is when I deploy the application to my WinCE device.

The problem that I encounter is when the application attempts to access the database when it needs to fill the Data Set with data.

The root of the problem is, the connection string to the database that is defined in the Data Set is per the dev machine – not the local path per the WinCE device.

For example: The connection string in the Data Set is set to

@"Data Source = C:\src\myApp\data\mydb.s3db"

instead of the full path of the target device similar to

@”Data Source = \Program Files\myApp\data\mydb.s3db”

I was able to fix the problem by manually editing the Data Set’s .Designer.cs file (at the InitConnection() method). However, it would be nice if VS2008 can manage the connection string for me somehow – i.e. when in dev mode, the connection string points to the database on my dev machine. When in deploy mode, the connection string points to the database on the device.

Is there a way to specify the connection string to point to a relative path rather than the full path, maybe? Or?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:45:45+00:00Added an answer on May 26, 2026 at 5:45 am

    Use “|DataDirectory|” in your connection string.

    Quote from http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/dc31ea59-5718-49b6-9f1f-7039da425296/ …

    |DataDirectory| (enclosed in pipe symbols) is a substitution string that indicates the path to the database. It eliminates the need to hard-code the full path which leads to several problems as the full path to the database could be serialized in different places. DataDirectory also makes it easy to share a project and also to deploy an application.

    For example, instead of having the following connection string:
    “Data Source= c:\program files\MyApp\Mydb.sdf”

    Using DataDirectory, you can have the following connection string:
    “Data Source = |DataDirectory|\Mydb.sdf”

    To set the DataDirectory property, call the AppDomain.SetData method. If you do not set the DataDirectory property, the following default rules will be applied to access the database folder:

    • For applications that are put in a folder on the user’s computer, the
      database folder uses the application folder.
    • For applications that
      are running under ClickOnce, the database folder uses the specific
      data folder that is created.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Form Application in Visual Studio 2008 - PictureBox.Refesh() method causes
I have to develop Windows C# application, using Visual Studio 2008. It have dynamical
I have a windows form application that uses a Shared class to house all
I have a Windows form application that users can log into. The application is
I have an Windows Form application that supplies the User Name, Domain, and Password
I have a windows form application that connects to a USB port. In the
I have a Windows form application that has a child form that pops up
I have a Windows Form application that, when the form is Activated, Deactivated, or
I have a Windows Form application that involves two Forms. The child form is
I have a Windows Form desktop CRUD application. The users are finding that if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.