Mobile Project DataSet Bug Clarification - The bug is NOT specific to VB

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.

You'll recall that on Tuesday I reported that there is a bug in the generated connection string when working with a SQL Mobile database in VB.NET. I turns out that there is a bug but it is not specific to VB.NET.

The bug in the generated connection string occurs anytime you add a reference to a table that is a keyword in the programming language you're using. Because the specific database files we were using were all related to real estate based examples, they all contained a table named "property". Of course "property" is a keyword in VB.NET but not C#. Had we had a table whose name was a C# keyword, we would've seen the same problem in the C# project. 

So to summarize…

Bug: When referring to tables contained in a SQL Mobile database, Visual Studio 2005 incorrectly sets the connection string in the generated table adapter-derived class when the generated table adapter-derived class refers to a table whose name is a keyword in the current project's language (C# or VB.NET).

Work-around: If possible, change the name of the table to a non-keyword. If for business or legacy reasons you are not able to change the problematic table's name, manually set the connection and connection string as shown in Tuesday's blog post.


Posted Mar 23 2006, 09:42 AM by jim-wilson

Comments

You Can Take it With You wrote VB-Only Bug in Mobile Project DataSet when accessing SQL Mobile
on 03-23-2006 7:52 AM
Sriram Krishnan wrote re: Mobile Project DataSet Bug Clarification - The bug is NOT specific to VB
on 04-10-2006 12:08 PM
Sorry you had to mail us about this - I usually read your blog but had not read any blog for 2-3 weeks.
gregmackers wrote re: Mobile Project DataSet Bug Clarification - The bug is NOT specific to VB
on 05-21-2007 8:22 PM
I noticed that in c# if you have the database in a subfolder it doesn't add the folder to the path. So initconnection doesn't work unless db and app in same folder.
Jim Wilson wrote re: Mobile Project DataSet Bug Clarification - The bug is NOT specific to VB
on 05-22-2007 6:24 AM
It sounds like you'll need to generate the connection string explicitly to include the subfolder. Something like this...

string runtimeFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) ;
string dbFilePath = Path.Combine(runtimeFolder, @"Data\Realestate.sdf") ;
this.Me.PropertyTableAdapter.Connection = New System.Data.SqlServerCe.SqlCeConnection("Data Source = " + dbFilePath & ";") ;

I think that'll do it.

- Jim

Add a Comment

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