Solved

Where to put the SQLServer CE database?

Posted on 2010-09-15
1
528 Views
Last Modified: 2012-05-10
I decided I needed to keep the database in only one location, since it was driving me nuts to have different copies of it around depending on whether I was in Debug mode or Design mode.   But I wanted to take advantage of the |DataDirectory| macro so I run the code attached on start up and I copied the database to that location....

My question is, does it make sense to put it at that location or is there a better approach?

I am interested in hearing your responses.

Thanks for your help.
Public Function SetDataString(ByRef lex As LastException) As Boolean
        ConnString = Application.CommonAppDataPath
        System.AppDomain.CurrentDomain.SetData("DataDirectory", ConnString)
        Return True
    End Function

Open in new window

0
Comment
Question by:codefinger
1 Comment
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
Comment Utility
Yeah - it can be frustrating to see / have that copy in the debug folder, but if it is part of your project then it will do that. Is this for mobile apps, or are you using the compact / CE database in other clients ?

As you say, you can create/customise your own connection string - have a look at Steve Lasker's code (an oldie but still good): http://blogs.msdn.com/b/smartclientdata/archive/2005/07/25/443034.aspx

For a general discussion about using the datadirectory macro, have a read of : http://blogs.msdn.com/b/smartclientdata/archive/2005/08/26/456886.aspx

There is also some good general information in msdn : http://msdn.microsoft.com/en-us/library/aa983341.aspx and look at that "local data" link : http://msdn.microsoft.com/en-us/library/ms233817.aspx it has some good walkthroughs and suggestions.

For us, we simply decided a most appropriate location for us, and used the approach per Steve's posting. We "bundled" our app in such a way that using a custom connection string meant that we always knew (also from a support perspective) exactly where the data was and how to get there... And that is kinda what the datadirectory achieves, so, looking back would have been a good choice, but, for some of our deployments (on mobile devices) we also had the app and data running from the sd card, so had to "roll our own" standards into our connection (and deployment).




0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

6 Experts available now in Live!

Get 1:1 Help Now