Thursday, March 29, 2012

General network error. Check your network documentation

I use sqlclient to connect directly from my mobile 5 pocketpc to a sql server 2005 database on my desktop.

I use a sqldatareader to traverse the results of a query that delivers 2 fields: (1) the filespec, and (2) the image field.

I use a filestream with a binary writer to write the contents of the image data to the pocketpc's storage card.

I have a test table with 10 images, not one more than 4 MB. I cannot complete a test run prior to receiving the general network error.

The pocketPC is connected via activesync to the desktop, and I connect to the database with:

Integrated Security=false;
user id=sa
password=admin.

Any help with this strange error would be greatly appreciated.

Wil

Will,

Using a SqlDataReader and the SqlClient from a device to a remote SQL Server database is a bad idea unless you have a 100% reliable network connection. Best case you can wrap your calls to dtr.Read() in a try catch and re-establish the connection and data reader if it drops, but what you are really doing is trying to keep an open cursor across a network to a remote db.

Better to grab what you need from SQL Server via RDA or an asynch web service call.

-Darren

|||

Hello Darren,

Thanks for your sensible reply...it was very helpful. I wonder why some sample code illustrates this technique for SqlClient if it is not generally advisable?

I will take a look at the alternatives you proposed.

Thanks again,

Wil Pannell

|||

Sure thing Wil - I think using the SQLClient makes sense in a cradled situation and if you have some local data caching established (using SQL CE/Mobile for example), you can get away with connecting over 802.11 as well, but you have to really protect yourself code-wise and assume the connection could drop at any moment.

-Darren

No comments:

Post a Comment