Not sure if you have an answer yet or not, but I this seems to work ok although probably not the best or most elegant solution .....
Public Sub changeUserPwd(ByVal userName As String, ByVal newPwd As String)
Dim conn As MySqlConnection
Dim connStr As String
connStr = String.Format("server={0};user id={1}; password={2}; database=WBA; pooling=false", _
"localhost", "root", "admin password goes here")
conn = New MySqlConnection(connStr)
Dim myCommand As New MySqlCommand
Dim myReader As MySqlDataReader
Dim SQL As String = "SET PASSWORD FOR ?UserName = PASSWORD(?myPwd);"
Try
Windows.Forms.Cursor.Current = Cursors.WaitCursor
conn.Open()
Try
With myCommand
.Connection = conn
.CommandText = SQL
.Parameters.AddWithValue("?UserName", Trim(userName.ToString))
.Parameters.AddWithValue("?myPwd", Trim(newPwd.ToString))
.ExecuteScalar() ' update
End With
myReader = myCommand.ExecuteReader
Catch ex As MySqlException
MsgBox(ex.Number & Chr(13) & ex.Message)
End Try
Catch ex As Exception
MsgBox(ex.Message)
Finally
closeSQLConnection(conn)
End Try
End Sub
I would not suggest hard coding the ip address or root password into the connection string but rather pass into the the sub as with the username & password. Hope this is of help. Bungle.