与MySQL Online的稳定连接 [英] Stable connection to MySQL Online

查看:112
本文介绍了与MySQL Online的稳定连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过VB.NET连接到MySql Online.但是连接始终是关闭的.那你有什么办法吗?请帮忙!

编辑-

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 -

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!

推荐答案

可能Cn_int变量是全局变量.您需要检查其他过程或功能以关闭连接.顺便说一下,这里.提供程序很多,连接字符串也很多.
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.


不要使用全局连接,也不要立即打开它.最好在需要时创建连接,打开它,进行查询,然后关闭它.
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.


这篇关于与MySQL Online的稳定连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆