Page 1 of 1

Various questions

Posted: Sat 29 Jul 2006 15:41
by classicmydac
I have managed to adapt the pitcures example's structure in my app to allow me to update data to MYSQL. The app takes images , text, date stamp etc. I then store all the data inc paths into a text file. I then populate the grid with data and images and update the tables.

Any pointers on the following appreciated.

The text file method works but I need to "hide" the text file. (End users cannot alter times etc for security reasons)

My app loads Form1 which contains a Updatebutton to "mySqlConnection.Open();" I then update on "mySqlConnection_StateChange". The app crashes if there is no connection. How Do I trap this error eg

if (mySqlConnection.State. 'failed') { close form}. Also is there a way to say "Press Updatebutton on form1" without opening the form.

Any sample c# code to force an internet connection if not available?

How do I put a splash screen after a button press. I have:
Form1 form1 = new Form1();
form1.Show();
but the screen take a while to update. How do I say "Loading please wait" and shut this down once the form is loaded.

I have no problems when connected via activesyn. I have done 100+ rows and the data flys. However when using GPRS I get a lost connection and only part of the data is sent across. The end user may be dropping out of service whilst moving. Any strategies for handling this sort of problem.

Many thanks for the help so far.

Posted: Tue 01 Aug 2006 07:28
by Alexey
To check connection state use MySqlConnection.Ping() method.
Unfortunately we cannot give you answers on other questions, because this exceeds goals of our support.

Syntax

Posted: Tue 01 Aug 2006 13:03
by classicmydac
What is the exact syntax please

{
if mySqlConnection.Ping() = true {

MessageBox.Show("connected ");
}
}

does not work

Cheers

Trap connection error

Posted: Tue 01 Aug 2006 15:40
by classicmydac
I call
mySqlConnection.Open();
if (mySqlConnection.Ping() == false)
{
MessageBox.Show("not connected");
mySqlConnection.Close();
}

to try and trap a no connection error but the pocket PC gives a "no connection to server "error dialog.

How do I trap this error please?

SteveW

Posted: Wed 02 Aug 2006 08:41
by Alexey

Code: Select all

{ 
if mySqlConnection.Ping() = true { 

MessageBox.Show("connected "); 
} 
} 
This is correct syntax. What exactly does not work?

Syntax

Posted: Wed 02 Aug 2006 09:51
by classicmydac
I have the syntax correct now, but the code above does not trap the error if the is no connection. IE no gprs / activesync connection to MYSQL.

Cheers

SteveW

Posted: Wed 02 Aug 2006 10:12
by Alexey
To catch any error you should have used try{} block.

try

Posted: Wed 02 Aug 2006 13:15
by classicmydac
I have

try
{

mySqlConnection.Open();

}
catch (Exception)
{
MessageBox.Show("Error");

}
finally
{
rest of code to update images etc
}


The above code captures the execption if not connected, but after clicking the message box I get the error connection must be openend. I thought the finally section only runs if there is no exeption. How do I stop the code running?

Posted: Thu 03 Aug 2006 06:27
by Alexey
Finally section runs in any case!