Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb .net 2005 connecting to MySQL database - Wont drop connection

Status
Not open for further replies.

markhkram

IS-IT--Management
Dec 30, 2008
32
US
I've created a simple MySQL database with the MySQL connector connecting in my vb .net 2005 project. Everything works & connects great. However, when using the command "show processlist;" in mysql command prompt, I see the open connection from my vb project, even after a "connection.close" and/or "connection.dispose". While accessing the db from my PHP webpage, the connection automatically closes instantly after connecting (which is what I want my VB project to do).

All I want is my program to access the database, close the connection, and never connect to the db again. Anyone know what I'm doing wrong?

Code:
       Try
            Dim connStr As String = "Database=mydb;" & _
                            "Network Address=192.168.10.101;" & _
                            "Port=3306;" & _
                            "User Id=dbuser;Password=shhh;" & _
                            "Connection Timeout=20" 
            Dim connection As New MySqlConnection(connStr)
            connection.Open()
            connection.Close()

            MsgBox("Connection is okay.")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 

In your connection string, try adding "pooling=false;" to disable connection pooling. The behavior you describe is expected if connection pooling is enabled, as the connection is set to Idle rather than Closed.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
You are a genius! Thanks it worked!

What benefit does Pooling have?
 
Ok, so I found out I need to connect to the database again while logged in. However with Pooling turned off, the connect time takes about 5 seconds to re-connect, and pooling turned on was less than a second. This is just awful, since I have thousands of users that will connect, but the 5 seconds is way too long to reconnect.

When accessing from my php page, it load instantaneously, and it is re-establishing it's connection every time.

My question now is how can I have pooling turned off, but have the response time that my php website has?
 
Someone else might have a better answer, but till then the answer is not really. That is part and parcel with the difference between pooling and not. I'm not the best in this area, but you might be able to set the time out on it.

Still if you are opening/closing the connection so much that 5 seconds is that important you might want to look at changing how you go about pulling your information or when to actually open/close the connection.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top