Various questions

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
classicmydac
Posts: 38
Joined: Fri 23 Dec 2005 11:51

Various questions

Post by classicmydac » Sat 29 Jul 2006 15:41

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.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 01 Aug 2006 07:28

To check connection state use MySqlConnection.Ping() method.
Unfortunately we cannot give you answers on other questions, because this exceeds goals of our support.

classicmydac
Posts: 38
Joined: Fri 23 Dec 2005 11:51

Syntax

Post by classicmydac » Tue 01 Aug 2006 13:03

What is the exact syntax please

{
if mySqlConnection.Ping() = true {

MessageBox.Show("connected ");
}
}

does not work

Cheers

classicmydac
Posts: 38
Joined: Fri 23 Dec 2005 11:51

Trap connection error

Post by classicmydac » Tue 01 Aug 2006 15:40

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

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Wed 02 Aug 2006 08:41

Code: Select all

{ 
if mySqlConnection.Ping() = true { 

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

classicmydac
Posts: 38
Joined: Fri 23 Dec 2005 11:51

Syntax

Post by classicmydac » Wed 02 Aug 2006 09:51

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

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Wed 02 Aug 2006 10:12

To catch any error you should have used try{} block.

classicmydac
Posts: 38
Joined: Fri 23 Dec 2005 11:51

try

Post by classicmydac » Wed 02 Aug 2006 13:15

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?

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Thu 03 Aug 2006 06:27

Finally section runs in any case!

Post Reply