Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
[no name] 31-Jul-13 4:52am    
www.connectionstrings.com

1 solution

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
 
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