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:
- Ensure that SQL Express is set to accept remote connections. By default this is disabled.
- Ensure that your SQL Server is set to accept SQL Server Authentication as well.
- Fix the port for the SQL Express database.
- Create the connection string with the IP and the Port. eg: Data Source = 192.168.1.2,1433;Initial catalog=Pubs;User Id=****, Password=***;
- 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.
-
1
Pingback on Jan 4th, 2011 at 7:11 am
[…] Connecting to SQL Server Express from a Pocket PC application March 2007 9 comments 5 […]
-
2
Pingback on Jan 11th, 2011 at 5:00 pm
[…] Accessing SQL Server Express from the emulator (or PDA) Connecting to SQL Server Express from a Pocket PC application […]
January 29, 2008 at 9:25 am
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
February 1, 2008 at 4:06 am
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
August 28, 2009 at 6:53 am
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
February 12, 2008 at 8:41 am
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
February 12, 2008 at 8:51 am
fd
September 7, 2009 at 6:53 pm
HI
I really need the source code urgent for connection pda with sql express,please email to my email (fauzi.chaniago@gmail.com). Thanks
October 9, 2009 at 12:14 pm
please send me the code, i’m developing a system for my degree final project.. i’m stuck, please send me the code.
October 17, 2009 at 11:12 pm
nice tips , bro, i will try it, thanks
October 22, 2009 at 11:53 am
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
February 10, 2013 at 11:44 pm
this image could be the best!
May 29, 2013 at 11:35 pm
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.
June 26, 2013 at 11:53 am
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.
September 22, 2014 at 3:33 pm
I everfy time uswd to read paragraph in news papers but now as I am a user of internet thus from now I am using net for articles
or reviews, thanks to web.
October 8, 2014 at 8:03 pm
You share interesting things here. I think that your page can go viral easily, but
you must give it initial boost and i know how to do
it, just search in google for – mundillo traffic increase go viral
January 8, 2015 at 6:06 am
I can’t hear aninyhtg over the sound of how awesome this article is.