2014-04-02 79 views
0

我收到此錯誤:「從流中讀取失敗。」mysql與vbnet的遠程連接

下面是我的代碼:

Imports MySql.Data.MySqlClient 

Public Class Form1 
    Dim dbds As New DataSet 
    Dim MySQLconn As New MySqlConnection 
    Dim SQLda As New MySqlDataAdapter 
    Dim cmd As MySqlCommand 

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

    MySQLconn = New MySqlConnection("server=www.address.com;User Id=user_nem;pwd=***;port=2082;database=db_db_db") 


    Try 
     MySQLconn.Open() 
     MsgBox("Sucess, press ok to continue…", vbOKOnly) 
     cmd.CommandText=(("set net_write_timeout=99999; set net_read_timeout=99999"), MySQLconn) 
     cmd.ExecuteNonQuery() 
     SQLda = New MySqlDataAdapter(("SELECT * FROM log_in"), MySQLconn) 
     SQLda.Fill(dbds, "doctors") 
     DataGridView1.DataSource = dbds.Tables("doctors") 

    Catch ex As Exception 
     MsgBox(Err.Description) 
    End Try 

End Sub 

End Class 

此代碼工作正常與我的本地主機。 任何幫助將不勝感激。謝謝。

回答

0

我猜mysql用戶user_nem只能通過localhost訪問數據庫。

嘗試創建一個用戶這樣

GRANT ALL PRIVILEGES ON yourDbName.* To 'myuser'@'%' IDENTIFIED BY 'password';

'myuser'@'%'指從任何位置%與名稱myuser用戶。 (不要忘記更新您的連接字符串中的用戶名)

我想現在它的東西就像'user_nem'@'localhost''user_nem'@'127.0.0.1'這就是爲什麼它在本地,但不是在遠程工作。

嘗試檢查防火牆也。