As many of you probably know, I'm not a big fan of using DataSets in Windows Mobile projects. I much prefer the far lighter-weight and faster SqlCeResultSet. Unfortunately, Visual Studio 2005 support for generating SqlCeResultSets is pretty limited.
I've talked before about changing the custom tool associated with your data sources *.xsd file from MSDataSetGenerator to MSResultSetGenerator and using my ExtendTypedResultSet snippet to improve your application's data performance [ In most cases using a SqlCeResultSet will improve your app's performance by 10x or more]. As much as these things help, I ran into another issue today when I moved a project from one computer to another.
When I opened my application's main form in design-mode on the new machine, I saw the following (somewhat scary) screen…

It turns out this problem is caused by the way Visual Studio generates the design-time connection string. Instead of making the connection string's path relative, the path is absolute as shown here…
if (NorthwindDataSetUtil.DesignerUtil.IsDesignTime()) {
// Designtime Connection String
resultSetConnectionString = "Data Source =\"C:\\Visual Studio Projects\\ImprovedDataPerformanceCS\\ImprovedDataPerformanceCS\\Northwind.sdf\"";
}
As a result, the path is only valid on the machine that creates the project or other machines that follow the same exact directory structure for their Visual Studio 2005 projects.
To correct this problem, locate the generated SqlCeResultSet's constructor and change the design-time path to be relative to the Visual Studio solution's folder. In the case of this example, the solution file (.sln) is located in folder named ImprovedDataPerformanceCS with the project located in a sub-folder with the same name. To make the path relative to the solution folder change the code as shown here…
if (NorthwindDataSetUtil.DesignerUtil.IsDesignTime()) {
// Designtime Connection String
resultSetConnectionString = "Data Source =\"ImprovedDataPerformanceCS\\Northwind.sdf\"";
}
This is one simple change now makes your project portable.
I haven't had a chance to play with ResultSets in Orcas yet but let's keep our fingers crossed that the experience is a little better there.
(BTW: I don't want to imply that there is a problem in the run-time connection string. This problem occurs only at design-time)
Posted
May 11 2007, 04:03 PM
by
jim-wilson