tags:

views:

29

answers:

1

Hi,

I have a program that reads from a serial port. the program works fine but, after reading 100 lines from the serial port i get the following error.

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: error connecting: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

I really don't understand what does it mean.

thanks, Sebastian

+1  A: 

I suspect your program is opening a MySQL connection to a non-existent server behind the scenes (maybe in another thread) before reading from the serial port. The error you see is a MySQL connect timeout and is not related to serial operations.

EDIT: Your comment below gave me better insight about your problem. I think you're opening a new MySQL connection for each iteration of your loop and you don't close it properly, so after a hundred iterations your connection pool is full and you can't connect to the server anymore.

Try to open the connection once outside of the loop, then close it properly when your job's done. The using statement is a good way to achieve that.

Frédéric Hamidi
i have a local MySQL server, the and the program adds 100 entries in my MySQL database, after that i receive that error.Any Ideeas?
sebastian
Can you post the code that adds the entries?
Frédéric Hamidi