Newbie nedd help

Feb 4, 2013 at 10:03 AM
Hello, I am trying to develop an application on windows mobile 6 and 6.5 PDAs. I use SQL CE 3.5 database. When i run the application in the emulator everything works as intended, but when i deploy it on the device when i try a select or any db operations i get an sqlce exception
"The operation completed successfully.". Any help would be much appreciated.
Coordinator
Feb 4, 2013 at 4:25 PM
I'd need to see more information, like the Entity definitions and how you're creating your store. WinMo PDAs are definitely supported and working.
Feb 4, 2013 at 6:28 PM
Well I tried to follow the example from the source code so here is what I got:

the entity class is named agenti and it looks like this

[Entity(KeyScheme.Identity)]
public class agenti 
{
    [Field (IsPrimaryKey = true, FieldName = "id") ]
    public Int64 id { get; set; }

    [Field (FieldName = "idAgent")]
    public Int64 idAgent { get; set; }

    [Field(FieldName = "nume")]
    public string nume { get; set; }

    [Field(FieldName = "prenume")]
    public string prenume { get; set; }
}
the data store is done in DataService class which looks like this:

public class DataService : SqlCeDataStore
{
    public SqlCeDataStore m_store;


    public DataService()
    {
        String full_path = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
        String directory_path = full_path.Substring(0, full_path.LastIndexOf("\\"));
        m_store = new SqlCeDataStore(Path.Combine(directory_path, "agentDB.sdf"), "marketing");
        m_store.DeleteStore();
        if (!m_store.StoreExists)
        {
            m_store.CreateStore();
        }
        m_store.DiscoverTypes(Assembly.GetExecutingAssembly());
        m_store.EnsureCompatibility();

    }

    public void addAgentTest()
    {
        var newAgent =  new agenti()
        {
            idAgent = 666,
            nume = "testNume",
            prenume = "testPrenume"
        };

        this.m_store.Insert(newAgent);
    }

}
the main function is a simple form just for some test and it looks something like this:
public DataService store;
public loginForm()
    {

        InitializeComponent();
        store = new DataService();
        List<agenti> listaAgenti = store.m_store.Select<agenti>().ToList<agenti>();
    }

    private void menuItemVerificare_Click(object sender, EventArgs e)
    {
        store.addAgentTest();
    }
I get the exception at the select and if i try to insert in the db. After some testings I noticed that if I replace List<agenti> listaAgenti = store.m_store.Select<agenti>().ToList<agenti>(); with somtheing simple like var listaAgenti=store.m_store.Select<agenti>(); I don't get the exception but as soon as i try to do something like listaAgenti.Count() i get the exception. (the Insert in db code alwasy gives the eexception). As i said in the emulator everything works fine only when I deploy on the device I get the exceptions. I tried this code without an existing db and let the code generate a database and added the store entity myself with m_store.AddType<agenti>(); but I get the same exception. This is where I am at the moment, and I am blocked. So any ideea?
Coordinator
Feb 5, 2013 at 1:54 PM
The device and emulator should behave identically, since the code is the same. If you look at the stack trace of the exception, where is it originating from?
Feb 5, 2013 at 2:04 PM
Well this is the exception's stack tree:
at System.Data.SqlServerCe.SqlCeDataReader.ProcessResults(Int32 hr)
at System.Data.SqlServerCe.SqlCeDataReader.FillMetaData(SqlCeCommand command)
at System.Data.SqlServerCe.SqlCeCommand.InitializeDataReader(SqlCeDataReader reader, Int32 resultType)
at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
Coordinator
Feb 5, 2013 at 2:11 PM
So the exception is saying "success" and the stack trace isn't even coming through the ORM (unless you've left part of the stack trace out). This is odd. If you run any of the tests/samples that ship in the ORM code on the device does it fail in the same way?