How to close a datasource mysql-connection

2019-09-10 05:10发布

问题:

Using VS2013, I have created a project. It consists of a service, which runs constantly while the computer is powered, and connects to a MySQL database.

I used the server explorer to create a dataset, and a number of tableadapters, and provided the connection details.

This gives me the dataset.xsd file.

This all works, but leaves the connection to the DB open while the computer is on.

This program will be running on >1000 machines at the same time, so once the datasets have been populated, the connection to the database can be closed, but I can find no way of doing this.

Can anyone suggest how I could close the connection to the underlying DB when it is not needed?

回答1:

Turns out that visualstudio / vb.net handles the connections automatically. I set the MySQL server to close sleeping connections after a short delay (a few seconds) and next time my program requires access it simply opens a new connection.