SqlCeResultSet and Visual Studio 2005 Project Portability

You Can Take it With You

Syndication

News

  • Don't miss the next Windows Mobile Webcast... Unit Testing for Mobile Devices: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032382824&EventCategory=4&culture=en-US&CountryCode=US.

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

Comments

B. Medlin wrote re: SqlCeResultSet and Visual Studio 2005 Project Portability
on 05-22-2007 10:02 AM
I appreciate these tips on SqlCE. This is good information, particularly when discussing the performance ramifications. Keep it coming.

Jim Wilson wrote re: SqlCeResultSet and Visual Studio 2005 Project Portability
on 05-22-2007 10:53 AM
B. Medlin;

Thank you for the kind words. I appreciate your feedback.

Thanks,
Jim
John S. wrote re: SqlCeResultSet and Visual Studio 2005 Project Portability
on 07-02-2007 4:52 PM
Hello Jim,

Thank you very much for your webcast about resultsets, I've just finished watching it.
This is amazing and definitly something I want to start using in my application. A quick question though, is there a way to easily convert from datasets to resultsets?

Thanks!
Jim Wilson wrote re: SqlCeResultSet and Visual Studio 2005 Project Portability
on 07-03-2007 7:26 AM
John;

Thank you for kind words regarding the webcast. I'm happy to hear that you found it useful.

Regarding the question, can you provide a little more detail?

I'm not sure of the exact nature of the question. Are you asking whether an existing DataSet definition can be converted to a resultset, whether existing code written for a DataSet can be easily changed to use a resultset or maybe something different?

I just want to be sure answer what you're asking. :-)

Thanks,
Jim

Add a Comment

(required)  
(optional)
(required)  
Remember Me?