vb如何连接服务器mysql数据库连接,如何使用VB.net连接Web服务器数据库是MySQL

Imports System.Data

Imports MySql.Data.MySqlClient

Imports System.Data.SqlClient

Public Class Form1

Dim serverstring As String = "server=....;user id=.....;password=.....;database=.....;"

Dim sqlconnection As MySqlConnection = New MySqlConnection

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

sqlconnection.ConnectionString = serverstring

Try

If sqlconnection.State = ConnectionState.Closed Then

sqlconnection.Open()

MsgBox("เชื่อมต่อสำเร็จ")

Else

sqlconnection.Close()

End If

Catch ex As Exception

MessageBox.Show("Error : " & ex.Message & "")

End

End Try

End Sub

this code this can use only Localhost, but how can I do if I want to connect to another Host online, Who know ..help me please

解决方案Really the only thing you need to change is the 'server=' part to the [IP/DomainName] and possibly specify a port. The other issue would be allowing a connection to the MySQL server through the firewall. Port 3306 is the default port for MySQL.

MySQL Connection Strings

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值