Arigato.
MyConnection
MyConnection
Mushi2.. I want to build an application which is using both online and offline. First I will check whether the connection can be made or not, if successfull the whole application will be using online connection if not it will use offline. But I don't know how to do it, should I use two MyConnection components? and then how to set the whole application to off or online without having two separate applications for online and offline?
Arigato.
			
									
									
						Arigato.
> But I don't know how to do it, should I use two MyConnection components?
If you need to connect to two MySQL Servers simultaneously you should use two instances of TMyConnection component. But if you try to establish connection to remote server and if it fails, you can just change setting of MyConnection component and try to connect to another (e.g. local) server.
> and then how to set the whole application to off or online without
> having two separate applications for online and offline?
If you mean under online mode connecting to remote server and under offline mode connecting to local server, you can use one MyConnection component with different settings for online and for offline mode.
			
									
									
						If you need to connect to two MySQL Servers simultaneously you should use two instances of TMyConnection component. But if you try to establish connection to remote server and if it fails, you can just change setting of MyConnection component and try to connect to another (e.g. local) server.
> and then how to set the whole application to off or online without
> having two separate applications for online and offline?
If you mean under online mode connecting to remote server and under offline mode connecting to local server, you can use one MyConnection component with different settings for online and for offline mode.
arigato guys! i did as u guys hv suggested 
try
dmIRM.CurrentConnection.Connected:=True;
ShowMessage('Online Mode: Connected to HQ Server.');
except
dmIRM.CurrentConnection.Username:='root';
dmIRM.CurrentConnection.Password:='1234';
dmIRM.CurrentConnection.Server:='localserver';
dmIRM.CurrentConnection.Database:='database';
dmIRM.CurrentConnection.Port:=3306;
dmIRM.CurrentConnection.Connected:=True;
ShowMessage('Offline Mode: Using local server.');
end;
but then if i shut down the HQ server, i will not try to connect to the
local database. meaning that it won't go to the except part. y? what can be done?
			
									
									
						try
dmIRM.CurrentConnection.Connected:=True;
ShowMessage('Online Mode: Connected to HQ Server.');
except
dmIRM.CurrentConnection.Username:='root';
dmIRM.CurrentConnection.Password:='1234';
dmIRM.CurrentConnection.Server:='localserver';
dmIRM.CurrentConnection.Database:='database';
dmIRM.CurrentConnection.Port:=3306;
dmIRM.CurrentConnection.Connected:=True;
ShowMessage('Offline Mode: Using local server.');
end;
but then if i shut down the HQ server, i will not try to connect to the
local database. meaning that it won't go to the except part. y? what can be done?
In this case if you try to send any command to server, error will be raised and the following sequence of the events of MyConnection will be called:
You can use these events to reconnect to local server.
			
									
									
						Code: Select all
  OnError
  BeforeDisconnect
  AfterDisconnect