Hello all - I have subscribed to Host1Free in because I am a novice programmer and I want to learn how to use SQL in my programs. I am currently trying to learn how to connect to an SQL DB from my application and then upload and download data to the database. Below is my VB.NET code for opening a connection, but it is not working. I think that the problem is that I am trying to access the server incorrectly. I would appreciate any help you can give.
I have also tried to connect using the direct ip address 71.215.225.9, but that doesn't work either.Code:Imports MySql.Data.MySqlClient Public Class uwMainForm Dim sqlServer As String = "cimpletest.128pro.net" Dim sqlUsername As String = "cimple_stuser" Dim sqlPassword As String = "MYPASSWORD" Dim sqlConnection As MySqlConnection Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sqlConnection = New MySqlConnection() sqlConnection.ConnectionString = "server=" & sqlServer & ";" & "user id=" & sqlUsername & ";" & "password = " & sqlPassword & ";" & "database=test" Try sqlConnection.Open() MessageBox.Show("Connection to Database has been opened.") sqlConnection.Close() Catch myerror As MySqlException MessageBox.Show("Cannot connect to database: " & myerror.Message) Finally sqlConnection.Dispose() End Try End Sub End Class
Thanks,
Igrado



LinkBack URL
About LinkBacks




Reply With Quote