Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to connect to MySql Online by VB.NET. But the connection is always closed. So do you have any way to do with this? Please help!

Edit -
VB
Sub StartInternetdb()
        Try
            Cn_int = New MySqlConnection
            Cn_int.ConnectionString ="Host=SQL09.FREEMYSQL.NET;Database=testdb;User ID=raniy;password=123456;Port=3306;charset=utf8"
            Cn_int.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information)
        End Try
 
End Sub


And when I try to run the command to select data from table in the first time it works, but when I do it again later, it shows the error. It means:

Connection must be open.

Please help me to establish the stable connection in order to make it not close at any time.

Thanks in advance!
Posted
Updated 22-Mar-12 10:55am
v3
Comments
Dave Kreskowiak 5-Mar-12 22:20pm    
Without seeing your connection code, and any error messages (EXACT text helps alot!) that you're receiving, it's pretty much impossible to tell you what's going on.
Varun Sareen 5-Mar-12 23:07pm    
correct
ckulasekaran 6-Mar-12 6:41am    
Post your sample code

Probably Cn_int variable is a global variable. You need to check other procedures or functions for closing connection. By the way, take a look here. There are many providers and many different connection-strings.
 
Share this answer
 
Do not use a global connection, and do not open it immediately. Better create the connection when it is needed, open it, do your queries, and close it thereafter.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900