2017-01-14 48 views
-1

我在我的PC(Windows 10)上安裝了獨立的Visual Basic應用程序。其中應用程序正在連接遠程服務器(IP爲192.1xx.x.xxx)。 當我運行應用程序時,它給出了一個錯誤;如何在Windows 10上更改MySQL中的默認本地主機ip

用戶連接失敗。缺少服務器/數據庫。無法連接MySql主機。

我有在應用程序中使用的VBScripts和MySQL數據庫。我不太瞭解VB使用腳本構建應用程序。任何人都可以指導我重建它嗎?

如何更改我的MySQL默認IP?它會解決我的問題嗎?

下面是一些代碼:

Sub con() 
    If System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern <> "dd/MM/yyyy" Then 
     MsgBox("System Date Format is: " & System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern & vbCrLf & _ 
       " compartable on British Date Format only.." & vbCrLf & _ 
       "Change Short Date format to : dd/MM/yyyy" & vbCrLf & _ 
       "And Try Again") 
     'System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern = "dd/MM/yyyy" 
     End 
    End If 
    Uid = "root" 
    'PWord = "xxxxx" 
    PWord = "xxxxxxxxxxx" 
    'PWord = "server2" 
    datbase = "xxxxx" 
    Myserver = "" 
    'Myserver = "192.xxx.x.xxx" 
    MyserverCRy = "xxxxxx" 
    'ConString = "server=" & Myserver & ";database=" & datbase & ";Uid=" & Uid & ";Pwd=" & PWord & ";MinimumPoolSize=10;maximumpoolsize=150;" 
    ConString = "server=" & Myserver & ";database=" & datbase & ";Uid=" & Uid & ";Pwd=" & PWord & ";Pooling=false;" 

    Try 
     DBcon.ConnectionString = ConString 
     DBcon.Open() 
     DBcomm.Connection = DBcon 
    Catch e As Exception 
     MsgBox("User Connection Fail" & vbCrLf & "Missing Server/Database" & vbCrLf & "Errors occurred during connection" & vbCrLf & e.Message, MsgBoxStyle.Critical, "Connecting Error") 
     'Application.Exit() 
     End 
    End Try 
    Try 
     DBcon1.ConnectionString = ConString 
     DBcon1.Open() 
     DBcomm1.Connection = DBcon1 
    Catch e As Exception 
     MsgBox("User Connection Fail" & vbCrLf & "Missing Server/Database" & vbCrLf & "Errors occurred during connection" & vbCrLf & e.Message, MsgBoxStyle.Critical, "Connecting Error") 
     End 
    End Try 
    Try 
     DBcon2.ConnectionString = ConString 
     DBcon2.Open() 
     DBcomm2.Connection = DBcon2 
    Catch e As Exception 
     MsgBox("User Connection Fail" & vbCrLf & "Missing Server/Database" & vbCrLf & "Errors occurred during connection" & vbCrLf & e.Message, MsgBoxStyle.Critical, "Connecting Error") 
     End 
    End Try 
    Try 
     dbcon_Insert.ConnectionString = ConString 
     dbcon_Insert.Open() 
     dbcomm_Insert.Connection = dbcon_Insert 
    Catch e As Exception 
     MsgBox("User Connection Fail" & vbCrLf & "Missing Server/Database" & vbCrLf & "Errors occurred during connection" & vbCrLf & e.Message, MsgBoxStyle.Critical, "Connecting Error") 
     End 
    End Try 
End Sub 
+1

尋求幫助:顯示您的代碼。同時顯示MySQL服務器配置的相關部分。 –

+0

您可以擴展* *「獨立的Visual Basic應用程序」*,我們在說什麼?,VB.Net,VB6編譯的可執行文件,VBA在Office應用程序或VBScript中?目前還不清楚你使用的是什麼以及VBScript適用於什麼位置。 – Lankymart

+0

獨立..我的意思是說它是一個可執行文件。 VB和.net被使用。這是一些代碼.. – var

回答

0
Myserver = "" 
'[...] 
ConString = "server=" & Myserver & ";database=" & datbase & ";Uid=" & Uid & ";Pwd=" & PWord & ";Pooling=false;"

你收到這個錯誤,因爲你定義Myserver爲空字符串。用正確的主機名或IP地址替換空字符串。

相關問題