Hi guys,
I need urgent help on how to connect to mySQL database of my office website from a desktop application.
The affected part of my code snippet used is as listed below:
Imports System.IO
Imports Microsoft
Imports MySql
Imports MySql.Data.MySqlClient
Public Sub InitialiseAPP()
Static loginTrial As Integer
Try
loginTrial += 1
strDB_Connection = strDB_Database & ";" & strDB_DataSource & ";" & strDB_UserAuthentication
connMySQL.ConnectionString = strDB_Connection
cInsertUpdate.ConnectionString = strDB_Connection
If connMySQL.State = ConnectionState.Open Then connMySQL.Close()
connMySQL.Open()
If connMySQL.State = ConnectionState.Open Then
connMySQL.Close()
If (strDB_DataSource <> My.Settings.DB_DataSource) _
Or (strDB_Database <> My.Settings.DB_Database) _
Or (strDB_UserName <> My.Settings.DB_UserID) _
Or (strDB_UserPassword <> My.Settings.DB_Password) Then
My.Settings.DB_DataSource = strDB_DataSource
My.Settings.DB_Database = strDB_Database
My.Settings.DB_UserID = strDB_UserName
My.Settings.DB_Password = strDB_UserPassword
My.Settings.Save()
My.Settings.Upgrade()
End If
End If
Catch ex As Exception
MsgBox("Error #" & Err.Number & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "Database Connection Error")
If loginTrial > 3 Then
MsgBox("Please contact administrator for access" & vbCrLf _
& "Application terminated!", MsgBoxStyle.Critical, "Intrusion Alert!")
End
End If
GetNewDataSourceConnection(strDB_DataSource, strDB_Database, strDB_UserName, strDB_UserPassword)
strDB_UserAuthentication = strDB_UserName & ";" & strDB_UserPassword
If strDB_DataSource <> "" Then
InitialiseAPP()
End If
End Try
End Sub
Public Sub GetNewDataSourceConnection(ByRef strDataSource As String, ByRef strDBName As String, ByRef strDBUserName As String, ByRef strDBPassWord As String)
'GetNewDataSourceConnection = ""
Try
With DB_Connect
.ShowDialog()
strDataSource = .pstrServerAddress
strDBName = .pstrDBName
strDBUserName = .pstrUserName
strDBPassWord = .pstrServerPassword
End With
Catch ex As Exception
End Try
End Sub
The DB_Connect in the GetNewDataSourceConnection() subroutine is a form where all parameter relating to the database are entered.
If I try localhost in the "Data Source" it will connect without stress but if I try to connect through our site "IP Address" I get the error below:
"Error 91: Object reference not set to an instance of an object"
If I try using the site address i.e. https//mysubdomain.mysite.edu, I get the following error
"Error #5: Unable to connect to any of the specified MySQL hosts"
With the last error, I have the conviction that connecting to the "IP address" is the best but how to address the missing link is my challenge.
I need urgent help please!!!!!!!