Solved

Where to put the SQLServer CE database?

Posted on 2010-09-15
1
531 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
ID: 33690430
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

791 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