Connecting to SQL Server Express from a Pocket PC application

I was recently trying to do a small sample application with SQL Express and Pocket PC’s. Basically I wanted to try out a code to automatically synchronize with a database running on a network, when the application was cradled.

My solution was very simple. I used a dataset in the PPC application and updated to and from it to the database.

From my previous experience with PPC applications under .NETCF1, I remembered that PPC apps need the IP of the database in the connection string. Also, you have to set the SQL Server Express to accept TCP/IP connections as well as SQL Server Authentication. Instructions for all of that can be found on Daniel Chong’s blog post. So I will not delve into that further here.

But the problem I faced was, no matter what I tried, I got an SqlException called “SQL Server does not exist or access denied.” I searched the web high and dry and I still I was baffled. Then I tried trying out different combinations for the connection string and I realized that my emulator was not connecting to my PC at all. Delving in deeper, I realized I was running a wrong ActiveSync version. I was running version 3.8 and Visual Studio 2005 requires version 4.0 or higher. So I upgraded my ActiveSync version and enabled network connectivity on the emulator, everything worked great!

So a few pointers to remember when accessing SQL Express databases from Pocket PC (.NETCF2.0) projects:

  1. Ensure that SQL Express is set to accept remote connections. By default this is disabled.
  2. Ensure that your SQL Server is set to accept SQL Server Authentication as well.
  3. Fix the port for the SQL Express database.
  4. Create the connection string with the IP and the Port. eg: Data Source = 192.168.1.2,1433;Initial catalog=Pubs;User Id=****, Password=***;
  5. SQL Server Express installs with an instance name. Never give this instance name in your connection string. eg: Data Source=192.168.1.2\SQLEXPRESS… This gave my application an error which could not be caught with exception handling within the managed code.

That’s about it. Hope this helps someone out there. Any questions or clarifications, just ask.

About these ads

  1. Balagangadharan

    Hi i have all the thingd you said, but still it not working, same error SQL SERVER DOESNOT EXIST,

    can u send sample application you made

    Please help me

    Thanks in Advance

    Regards
    Balagangadharan.R

  2. priya

    i need the above said programming code.im doing my project in smart device application in which im connecting my pocket PC to a database.can u plz send the code to connect or give Balagangadharan’s id

    • suresh kaudi

      hi,

      i am suresh kaudi i have a problem in connection between sqlserver to pda application. when i make connection between pad to compact database it working perfectly but server connection time showing exception error pls help.

      thanks and regards
      Suresh Kaudi

  3. Balagangadharan

    Hi Priya,

    I done all the things and all the ways said in forums and net, but still its connecting the DB.
    if u got solution, please mail me.

    Thanks in Advance

    Regards
    balagangadharanr@rediffmail.com
    Balagangadharan.R

  4. fauzi

    HI

    I really need the source code urgent for connection pda with sql express,please email to my email (fauzi.chaniago@gmail.com). Thanks

  5. ajitha

    please send me the code, i’m developing a system for my degree final project.. i’m stuck, please send me the code.

  6. nice tips , bro, i will try it, thanks

    • Santosh

      Nice tips bro, but I would appreciate if you would throw out some coding to simplify things so that even people like me who are new to mobile applications development would benefit

  7. this image could be the best!

  8. Hi to every one, for the reason that I am genuinely keen of reading this
    web site’s post to be updated regularly. It consists of good data.

  9. maindak

    Thanks so much, was trying to find out if these device apps can connect to DB servers directly and found the answer in your post.

  1. 1 2010 in review « Sampath’s Mindspace

    [...] Connecting to SQL Server Express from a Pocket PC application March 2007 9 comments 5 [...]

  2. 2 Useful Links for .NET Compact Framework & Windows CE & Windows Mobile | Warren Tang's Blog

    [...] Accessing SQL Server Express from the emulator (or PDA)  Connecting to SQL Server Express from a Pocket PC application [...]




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s



Follow

Get every new post delivered to your Inbox.

%d bloggers like this: