How do I connect to MySql on a linux server with VB.NET?

How do I connect to MySql on a linux server with VB.NET and how to connect to an imap server in linux with
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First install a MYSql driver on your windows box...

Then work out what your DSN (Data Source Name) is...
then heres some code...

Private Sub cmdConnectMySQL_Click()

Dim cnMySql As New rdoConnection
Dim rdoQry As New rdoQuery
Dim rdoRS As rdoResultset

' set up a remote data connection using the
' MySQL ODBC driver.
' change the connect string with your username,
' password, server name and the database you
' wish to connect to.

cnMySql.CursorDriver = rdUseOdbc
cnMySql.Connect = "uid=YourUserName;pwd=YourPassword;server=YourServerName;" & _
    "driver={MySQL ODBC 3.51 Driver};database=YourDataBase;dsn='';"

' set up a remote data object query
' specifying the SQL statement to run.

With rdoQry
    .Name = "selectUsers"
    .SQL = "select * from user"
    .RowsetSize = 1
    Set .ActiveConnection = cnMySql
    Set rdoRS = .OpenResultset(rdOpenKeyset, rdConcurRowVer)
End With
' loop through the record set processing the
' records and fields.

Do Until rdoRS.EOF
    With rdoRS

      ' your code to process the fields
      ' to access a field called username you would
      ' reference it like !username
    End With

' close record set
' close connection to the database


End Sub

also here:

juanfigsAuthor Commented:
And what components I need or what else because I paste all that and I put the username, hostname and everything and I still have errors.

rdoconnection not defined
rdoquery not defined
rdoresultset not defined
Tommy KinardCommented:
Under References add Microsoft Remote Data Object 2.0


You can try this and let me know.

This code will display the records in a msgbox you can use that just to testit for now.

You have to add the adodb reference      

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
                                      Handles MyBase.Load    
        Dim conn As ADODB.Connection
        Dim rs As ADODB.Recordset
        conn = New ADODB.Connection()
        rs = New ADODB.Recordset()
        conn.Open("Driver={MySQL ODBC 3.51 Driver};
        rs.Open("select * from table", conn, ADODB.CursorTypeEnum.adOpenDynamic,
        Do While Not rs.EOF
        rs = Nothing
        conn = Nothing
end sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.