Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Fastest connectionstring for .NET connector (4 replies)

$
0
0
Hello,

I'm using the latest version of .NET connector and mysql server 5.5 to connect to a local database

the code is the following:

Public Sub OpenConn()
Public conn As MySqlConnection

If Not conn Is Nothing Then conn.Close()

Try
conn = New MySqlConnection("server=localhost;user id=root; password=mypassword; database=test; pooling=false")
conn.Open()
Catch ex As MySqlException
MessageBox.Show("Error connecting to server: " + ex.Message)
End Try
end sub

This code take about 1.5 sec (1500 ms) to connect to the server and database

In my project, I don't want to let the connection open.

So I open the connection, retrieve informations and close the connection. This adds in security and lower the risk of database corruption in case of power failures for instance.

Now with this approach, I will have to connect many times to the the server and it will cost time and ultimately slows my application.

I used the same approach with ODBC connector 3.51, and it worked like a dream. the connection is so fast (instantaneously)

So please can you tell if it is possible to have faster connection to the server using .NET connector ?

Is there other options in the connectionstring which can make the connection faster ?

Regards

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>