Question

I created a simple test that opens a connection of sqlce located on my Desktop P.C. When i start Run the debug mode it throws me that it cant open the connection. I use Pocket P.C 2003 EMULATOR

This is my Test Code on my Smart Device Application.

Connection string

private SqlCeConnection conn = new SqlCeConnection("Data Source=C:\\SDB.sdf");

test Connection

public bool test() 
{
    try
    {
        conn.Open();
        {}
        Status.TEXT = "CONNECTED";
    }
    catch (Exception ee) 
    {
        throw ee;
        Status.TEXT = "NOT CONNECTED"; 
    }
    finally
    {
        if (conn.State == ConnectionState.Open) conn.Close(); 
    }
    return true; 
}

Is there things need to configure?Thanks in Regards!

Was it helpful?

Solution

That's correct behavior. For most aspects, the emulator is just like a physical device that is nesxt to your PC. It doesn't know about your PC drives (you can share a PC folder by going into the Emulator configuration) and therefore can't see them. It also doesn't know anything about drive letters.

If you want the emulator to use a file on your PC, again you can share the folder the file is in, then it would be located at \storage card\myfile.sdf. Note that the shared folder gets mounted as "storage card" on the emulator.

I'd still recommend not doing this, though, since it's not at all extensible or scalable. The real solution isn't going to be running on an emulator on your PC is it? What happens when you test on real hardware that can't share a folder like the emulator? I'd say you should be deploying the database file to your device, whether that's the emulator or real iron.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top