Connecting to SQL 2005 from a Windows Mobile Device

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 a database. It is ok if it only connects to the SQL Server when it is docked.

I have never worked with mobile devices, so I may be thinking about this the wrong way. I created a DataSet and TableAdapter just like in a normal desktop application, but when I run the application in the emulator, I get a SqlException when I try to open a connection to the TableAdapter.

Is there something obvious that I am missing? Do I need to explicitly tell the emulator how it is docked? Do I need to configure it to make sure it is online? I can ping the SQL server in question from the application, so there must be some kind of connectivity

+2


source to share


2 answers


Here's a good link for setting up an emulator for network connectivity:

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



psasik

polite when he describes the emulator's network connections as "squirrelly". I've never gotten them to work successfully, but this is because I always have a real physical device that I always return to the first hint of emulator problems.

+2


source


Thanks for the link! This was helpful and I can confirm that I can connect to the network. Unfortunately, it still won't connect to the SQL server. I redid the code 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 a SQLException in myConn.Open () with errorClass 20, number 17. The message "SQL Server does not exist or is not available". The exact same code (copy / paste) works fine in a winforms app. Am I doing everything right? Is it possible that the code is correct, but that the emulator is causing my problems? Would like to ask the boss for a mobile device to try it?

+2


source







All Articles