views:

64

answers:

3

I'm using Subsonic 3.0.0.3 Active Directory. During program work, opens many connections to MySQL data base. I can see this threads in MySQL Administrator. I'm working with data base in this case:

var db = new DB();
var nClient = Enumerable.First(db.clients, c => c.id_client == cl.ID);
nClient.data = data;
nClient.Update();

another examlpe

var nClient = new client { data= cl.data };
nClient.Save();

How should i correctly close conection to dabase? Or how to use only one connection to dabase?

+1  A: 

It will close the connection straight way. SubSonic was designed to only open the connection when needed and close when finished.

If you want to use the same connection for several queries you need to look in to the batch query

TWith2Sugars
A: 

But why in MySQL administrator I can see many threads?

The reason maybe because of pooling , check that your connection string has pooling disabled
RC1140
A: 

Thanks. I just add to connection string Pooling=false;