• Welcome, Guest. Please login.
 
January 24, 2021, 06:28:32 PM

News:

Welcome to the SQLitening support forums!


DUAL CONNECTIONS

Started by D. Wilson, January 13, 2011, 03:23:37 AM

Previous topic - Next topic

D. Wilson

What I would like to do is to connect to two (2) servers at the same time. One would be the primary and the other would be a backup server. I would put updates/inserts on both servers. I would try and get my records from the primary server and then 'fall back' to the backup server. Right now I am opening/closing the connection. Is there any easier way? My code is working great. I am just trying to find any alternatives. I know there is a function that allows me to test my connection state. I am just trying to figure out if I can open both connections at once.

Rolf Brandt

You can use slGetStatus to test for connections.
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

D. Wilson

I am aware of the getstatus command. But my question was -- is it possible to have two connections at the same time

Rolf Brandt

Sorry, I guess I misinterpreted that.

So I assume you are running two server instances with different ServerSuffixNames. Since only slConnect has the connection name as parameter I think you cannot do that from the same program. You probably can do from the same machine from two different programs. I think Fred needs to clarify this. He might hava some other tricks.
I like to cook with wine - sometimes I even add it to the food.
www.rbsoft.eu

D. Wilson

The way I set things up things are working great. I send it to the primary and then the backup server. There is no speed issue. I was just asking if there was an easier way.

In fact I am amazed at how fast SQLitening is.

Fred Meier

QuoteIs it possible to have two connections at the same time?
Yes, but each connection must be in a different thread.  This would seem
to be a great solution for what you are doing.  The main thread could
update your primary database while the second thread updates the backup
database.  See ExampleD for multi thread usage.

You would need to use global variables to communicate between the threads. 
Be sure you use a function like InterlockedExchange to prevent more than
one thread from using the same variable simultaneously.