views:

269

answers:

2

I am trying to write a simple application that runs on a Windows Mobile 6 device and can connect to a SQL 2005 server and read and write to the database. It is ok if it only connects to the SQL server while it is docked.

I have never worked with mobile devices, so I may be thinking about it incorrectly. I created a DataSet and a TableAdapter like I would with a regular desktop app, but when I run the application in the emulator, I get a SqlException when I try to open the connection on the TableAdapter.

Is there something obvious I'm missing? Do I need to explicitly tell the emulator to act like it is docked? Does it need to be configured to see that it is in the network? I can ping the SQL server in question from within the app so there should be some connectivity

+1  A: 

Here's a good link for setting up your emulator to connect to a network:

http://www.xdevsoftware.com/blog/post/Enable-Network-Connection-Windows-Mobile-6-Emulator.aspx

psasik is being polite when he describes emulator network connections as "squirrelly". I've never gotten them to work successfully, but this is because I always have an actual physical device handy, which I always go back to at the first hint of emulator problems.

MusiGenesis
Absolutely! The emulator is good for initial prototyping of UI layouts and not much more. Anything that has to do with connectivity or time gets completely hosed.
ctacke
@ctacke: the only practical use I've found for the emulator so far is answering CF questions when I can't find the connector cable for my smartphone and generating screenshots.
MusiGenesis
"Get a physical device" was the correct answer
rotard
A: 

Thanks for the link! It was helpful, and I can confirm that I can connect to the network. Unfortunately, it still will not connect to the SQL server. I have distilled the code down to:

`

        string connStr;
        System.Data.SqlClient.SqlConnection myConn;

        try
        {
            connStr = @"Server='<server name/IP>';Database=<database name>; User Id=sa; Password=<password>";
            myConn = new System.Data.SqlClient.SqlConnection(connStr);
            myConn.Open();
        }
        catch (System.Data.SqlClient.SqlException se)
        {
            MessageBox.Show(se.ToString());
        }

`

This code throws an SQLException at the myConn.Open() with errorClass 20, number 17. The message is "SQL Server does not exist or access denied." The exact same code (copy/pasted) works perfectly in a winforms application. Am I doing everything correctly? Is it likely that the code is correct but that the emulator is causing my problems? Would it be worth asking the boss for a mobile device to try it on?

rotard