SqlCeDataReader.GetSchemaTable() in SQL Mobile

by Administrator 22. May 2006 14:19

Here is my bug from Friday.  I have code something like the following that works in SQL CE 2.0:

string sql = "select field1, field2 from Table";
string conStr = @"Data Source=\Stuff.sdf";
SqlCeConnection con = new SqlCeConnection(conStr);
con.Open();
SqlCeCommand command = new SqlCeCommand(sql, con);
SqlCeDataReader reader = command.ExecuteReader();
SqlCeCommand updateCommand = null;
StringBuilder message = new StringBuilder();
while (reader.Read())
{
object[] vals = new object[reader.FieldCount];
reader.GetValues(vals);
if (null == updateCommand)
{
//... if first record, build update command
DataTable dt = reader.GetSchemaTable();
foreach (DataRow row in dt.Rows)
{

string colName = (string)row["ColumnName"];
message.Append(colName);
message.Append("=");
message.Append(row["ColumnSize"]);


}
}
}

This code merges data from "temp database" into permanent database.  Due to the # of tables merging the commands are built by reading the schema of the tables in the to-be-merged database.  Some of this code I inherited from someone else, and it works, or I might see about using  SqlCeCommandBuilder, but that is a post for another day.  This code reads all records from a merge table, and if it is the first record, build update and insert commands using the Schema Table.  In SqlCE 2 this works fine.  In SQL Mobile, if you call GetSchemaTable() after you have read the first record from the reader then the ColumnSizes contained in the schema table will be incorrect, reflecting the data in the current record rather than the schema of the table.  This results in things like truncated data errors if the first record has 5 chars in a varchar(20) field, etc.  The code works as expected if the GetSchemaTable() method is called before you begin reading records.

I can't find anything in the doc describing this as expected behavior, so its submitted as a bug.

Tags:

SQL Mobile Schema

by Administrator 19. May 2006 22:17
I found a great SQL Mobile bug with ColumnSize today which I can reliably reproduce.  I am going to go find out where I submit this bug and scheck to see if its already been submitted, and then post an exaple here of how to reproduce it.

Tags:

Speaking

by Administrator 16. May 2006 19:53
Tomorrow night I will be speaking at the Fox Valley .NET User's group, giving a presentation of the Compact Framework version 2.  If you're in the Appleton area, stop by and say hi.

Tags:

StarUML

by Administrator 10. May 2006 19:17

For now I will be using StarUML, untill I find something incredibly annoying with it or I find something better.  This tool has full support for UML 2.0 diagrams and semantics, seems to be a native win32 app (not some mind numbingly slow Java gui) and is generally straightforward.  StarUML also includes the notion of an "approach" to modeling: Basic approach, 4+1 view model, Rational Approach, and UML Components approach.  UML components was a great, precise,  but seemingly little known book written by a couple of modeling old-schoolers, one of whom was the author of Object Constraint Language, annexed to the UML.  I figured any tool that has a UML Components icon has to be on the right path and I spent a lot of time learning this tool.

Here is a partial class diagram I just did:

And a sequence diagram I am starting on with an idea of what the UI looks like

My complaints are small so far.  There are some user gestures (like Ctrl-Tab to switch documents) that I'd like to see impemented.  One nice thing that Visio and other tools do is to route relationships/connectors with only right angles which I think looks very nice.  StarUML has the ability to export models in XMI or Rational specific format as well, mitigating the risk that I'll change my mind and go with another tool later and need to scrap the drawings I have.

Tags:

UML Tools

by Administrator 9. May 2006 20:48

Today I had my final straw with Visio's UML support, mostly in how it attempts to "validate" my model for me.  The UML support appears to be an afterthought anyway.  I need to create some models for posterity and leave behind the models as well as instructions on obtaining the (hopefully free or cheap) tool to open the models.  My last Real modeling was done in Rational which is not an option for me right now.  I have used ArgoUML in the past and ultimately didn't care for it.  My next attempt today was Together's Design tool plug in for Visual Studio.  I had to register to download the eval , strike one.  I had to install some ridiculous Borland specific download manager Active X plug in, which scored me a completely corrupted download the first time I ran it, strike two.  Upon installation either the very simple License key instructions (save this file to My Documents) or the license key itself were wrong and the add-in wouldn't run due to license validation failure, strike three, uninstall.

I then headed over to http://www.uml.org/#Links to find a list of tools supporting UML 2.0.  I am currently downloading "StarUML" and I'll report back based on what I find.

I'm still disappointed that Microsoft does not have a REAL modeling tool to compete with Rational/IBM.  Visio and the Class Designer in VS2005 don't cut it.  If anyone has suggestions let me know.

Tags:

About the author

Damon Payne is a Microsoft MVP specializing in Smart Client solution architecture. 

INETA Community Speakers Program

Month List

Page List

flickr photostream