RE: SQL Err when WLAN conn is dropped and then restored. Help!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Flattron (danlee_73_at_hotmail.com)
Date: 08/17/04


Date: Mon, 16 Aug 2004 19:23:03 -0700

I just read this article, Hope it will help you .
http://msdn.microsoft.com/mobility/windowsmobile/default.aspx?pull=/library/en-us/dnnetcomp/html/networkcomponent.asp

Regards!

DanLee

"Flattron" wrote:

> Hi,
> First ,Thanks for your quickly reply every much! :-) , My problem is
> slolved.This caused by the Windows XP service pack 2,There is firewall
> installed, so PPC can not access the SQL server in the PC.I just allow 1433
> port .all things is OK.
> As your question , I test in my PPC, When I successful connect database
> via wireless LAN,I unplug the wireless router 'power and wait a few minutes,
> plug the power of wireless router.I try connect with database again,It seem
> very slowly , but 5 second, It can connect with database.
> I believe, you should first make sure the PPC can get ip address which
> assign by the server.and then ,try to connect with server with Tcp/IP ,after
> everything is Ok, then connect with SqlServer, I believe it can be OK .
>
> Another advice is check the wireless setting in the PPC,some power saving
> setting maybe make wireless connection lose.
>
>
> Regards!
>
> Dan Lee
>
>
> "Callon Campbell" wrote:
>
> > Hi,
> > Your problem isn't the same as mine, but I'll do my best to help you out.
> > First of all I would change your program so that your SQL code is in stored
> > procedures. You can then test the sp in query analyzer to make sure it works.
> > You can also test the connection to the DB as your user ID.
> >
> > If all this works, then go and test with your PDA. I'm actually storing my
> > connection string in an XML config file on my PDA. But the value looks like
> > this:
> >
> > <configuration>
> > <appSettings>
> > <add key="ConnectionString" value="SERVER=192.168.1.100; DATABASE=MyDevDB;
> > USER ID=UserCE; PASSWORD=UserCE" />
> > </appSettings>
> > </configuration>
> >
> > In my code I do the following...
> >
> > public bool Function1(int locationID, ulong scannedUnitCode)
> >
> > {
> >
> > bool isSuccess = false;
> >
> >
> >
> > SqlConnection myConnection = new
> > SqlConnection(connection.ConnectionString);
> >
> >
> >
> > try
> >
> > {
> >
> > try
> >
> > {
> >
> > myConnection.Open();
> >
> >
> >
> > SqlCommand myCommand = new
> > SqlCommand("Some_StoredProc", myConnection);
> >
> > myCommand.CommandType =
> > CommandType.StoredProcedure;
> >
> >
> >
> > // Input Parameters
> >
> > SqlParameter paramLocationID =
> > myCommand.Parameters.Add("@LocationID", SqlDbType.Int);
> >
> > paramLocationID.Value = locationID;
> >
> >
> >
> > SqlParameter paramUnitCode =
> > myCommand.Parameters.Add("@UnitCode", SqlDbType.BigInt);
> >
> > paramUnitCode.Value = scannedUnitCode;
> >
> >
> >
> > // Output Parameter
> >
> > SqlParameter paramSuccess =
> > myCommand.Parameters.Add("@Success", SqlDbType.Bit);
> >
> > paramSuccess.Direction =
> > ParameterDirection.Output;
> >
> >
> >
> > try
> >
> > {
> >
> > myCommand.ExecuteNonQuery();
> >
> >
> >
> > isSuccess = bool.Parse(
> > paramSuccess.Value.ToString() );
> >
> > }
> >
> > catch (SqlException SQLE)
> >
> > {
> >
> > MessageBox.Show(SQLE.Message, "SQLError");
> >
> > }
> >
> > catch (Exception E)
> >
> > {
> >
> > MessageBox.Show(E.Message, "Error");
> >
> > }
> >
> > }
> >
> > catch (SqlException E)
> >
> > {
> >
> > MessageBox.Show(E.Message, "Error");
> >
> > }
> >
> > catch (Exception)
> >
> > {
> >
> > MessageBox.Show("Could not connect to the
> > Database. Check that your within wireless coverage and try again. Contact
> > tech support if this persists.", "Error");
> >
> > }
> >
> > }
> >
> > finally
> >
> > {
> >
> > myConnection.Close();
> >
> > }
> >
> >
> >
> > return isSuccess;
> >
> > }
> >
> >
> > I hope that helps. What I didn;t give you is the source to the XML, but this
> > can be easily obtained from the PocketVision sample app. The Connection class
> > simply has a property that only gets the connection string, which gets this
> > from the XML config.
> >
> > Anyway I hope that helps. The PPC has limited debugging support and I have
> > more times then I can remember stumped myself on data access because of
> > simple little things. That is why always test the user account and stored
> > proc with actual data in query analyzer before trying to test on actual
> > device/emulator.
> >
> > Cheers,
> > Callon
> >
> >
> > "Flattron" wrote:
> >
> > > My problem is I can connect SQL2000 via activeSync,but when I connect with
> > > wireless lan to SQL2000,there always happen SQLexception ,the server is not
> > > exist or can not access,Can you tell me how about the connection string ?I
> > > use sqlclient to connect DB
> > > The connection string is :
> > > "User ID=sa;Password=sa;Initial Catalog=Northwind;Server=192.168.1.100;Data
> > > Source=192.168.1.100"
> > > Is there any problem in the connection string ?
> > >
> > > The code as following :
> > >
> > > Dim scnnDB As SqlConnection
> > > Dim sReader As SqlDataReader
> > > Dim scmd As SqlCommand
> > >
> > > scnnDB = New SqlConnection(SQL_CONNECTION_STRING)
> > > scmd = New SqlCommand("INSERT INTO FeederID_Mobile
> > > VALUES('asdf','asdf',34,'Nil')", scnnDB)
> > > Try
> > > scnnDB.Open()
> > > scmd.ExecuteReader(CommandBehavior.CloseConnection)
> > > scnnDB.Close()
> > >
> > > "Callon Campbell" wrote:
> > >
> > > > Hi,
> > > >
> > > > I've developed a CF application that communicates to a backend SQL Server
> > > > 2000 DB over a WLAN. It is working fine, but occasionally the wireless PPC
> > > > looses it;s connection while the application is running. the next time a user
> > > > goes to hit the SQL DB (note: everytime a user goes to the SQL server, an
> > > > SqlConnection object is created and opened. I then close it when my data has
> > > > come back and I'm done using it), I get an error saying the DB doesn't exist.
> > > > If I quit the application and re-start it will work fine.
> > > >
> > > > What would be causing this problem (not the dropping of the WLAN, but the
> > > > error occuring AFTER the connection to the WLAN is restored and the user goes
> > > > to communicate to the DB)?
> > > >
> > > > Any help would be greatly appreciated. I can send sample code of one of my
> > > > functions for reference if need be. Just send me an email and I'll reply back.
> > > >
> > > > Thanks in advance
> > > >
> > > > Cheers,
> > > > Callon



Relevant Pages

  • Re: Wireless Network and ActiveSync
    ... so any wireless network experts out there HELP!!! ... Make sure your wireless is working okay. ... Make sure you can talk to your PC from the PPC. ... No connection - reboot the PC and retry. ...
    (microsoft.public.pocketpc)
  • RE: SQL Err when WLAN conn is dropped and then restored. Help!
    ... As your question, I test in my PPC, When I successful connect database ... via wireless LAN,I unplug the wireless router 'power and wait a few minutes, ... > You can also test the connection to the DB as your user ID. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Adhoc connection
    ... Easy enough - set up the laptop's Ethernet connection for Internet ... Connection Sharing and it should just work. ... the wireless link for a long time, the risk of being hacked increases, but ... > speedstream wireless card for my laptop and a D-link for my PPC. ...
    (microsoft.public.pocketpc.wireless)
  • Adhoc connection
    ... I was going over some posts and there was a mention about adhoc wireless ... connection, Is this the same as something like peer-to-peer wireless ... speedstream wireless card for my laptop and a D-link for my PPC. ...
    (microsoft.public.pocketpc.wireless)
  • RE: SQL Err when WLAN conn is dropped and then restored. Help!
    ... I'm wondering though if you have any connection code you might ... so PPC can not access the SQL server in the PC.I just allow 1433 ... > via wireless LAN,I unplug the wireless router 'power and wait a few minutes, ...
    (microsoft.public.dotnet.framework.compactframework)