SqlCeResultSet Problem
Posted
by Vlad
on Stack Overflow
See other posts from Stack Overflow
or by Vlad
Published on 2009-12-10T08:46:05Z
Indexed on
2010/04/06
4:23 UTC
Read the original article
Hit count: 266
Hello,
I have a SmartDevice project (.NetCF 2.0) configured to be tested on the USA Windows Mobile 5.0 Pocket PC R2 Emulator. My project uses SqlCe 3.0. Understanding that a SmartDevice project is "more carefull" with the device's memory I am using SqlCeResultSets. The result sets are strongly typed, autogenerated by Visual Studio 2008 using the custom tool MSResultSetGenerator.
The problem I am facing is that the result set does not recognize any column names. The autogenerated code for the fields does not work. In the client code I am using
InfoResultSet rs = new InfoResultSet();
rs.Open();
rs.ReadFirst();
string myFormattedDate = rs.MyDateColumn.ToString("dd/MM/yyyy");
When the execution on the emulator reaches the rs.MyDateColumn the application throws an System.IndexOutOfRangeException.
Investigating the stack trace
at System.Data.SqlServerCe.FieldNameLookup.GetOrdinal()
at System.Data.SqlServerCe.SqlCeDataReader.GetOrdinal()
I've tested the GetOrdinal method (in my autogenerated class that inherits SqlCeResultSet):
this.GetOrdinal("MyDateColumn"); // throws an exception
this.GetName(1); // returns "MyDateColumn"
this.GetOrdinal(this.GetName(1)); //throws an exception :)
[edit added]
The table exists and it's filled with data. Using typed DataSets works like a charm. Regenerating the SqlCeResultSet does not solve the issue, the problem remains.
The problem basically is that I am not able to access a column by it's name. The data can be accessed trough
this.GetDateTime(1)
using the column ordinal.
The application fails executing this.GetOrdinal("MyDateColumn")
.
Also I have updated Visual Studio 2008 to Service Pack 1. Additionaly I am developing the project on a virtual machine with Windows XP SP 2, but in my opinion if the medium is virtual or not should have no effect on the developing.
Am I doing something wrong or am I missing something?
Thank you.
© Stack Overflow or respective owner