View Single Post
  #13  
Old 06-20-2008, 09:13 AM
nosfentora
Discordant
 
Join Date: Oct 2004
Location: In a house
Posts: 377
Default

Hey GeorgeS,

Once you have MySQL Connector.Net 5.1.6 installed,
add a reference to it (MySQL.Data)


Code:
Imports MySql.Data.MySqlClient
Public Class MyClass

    Private mydb As New MySqlConnection()
    Private con_str As String = ""
    Private reader As MySqlDataReader

    Public Sub New()
        con_str = "server=SERVER_IP;Port=3306;user id=root;password=PASSWORD_HERE;database=DATABASE_NAME;persist security info=True"
        mydb.ConnectionString = con_str

        mydb.Open()

        Dim sql_cmd as String = "SELECT * FROM variables"
        Dim cmd As New MySqlCommand(sql_cmd, mydb)

        reader = cmd.ExecuteReader
        While reader.Read
            For i As Integer = 0 To reader.FieldCount - 1
                debug.WriteLine(reader.Item(i).ToString)
            Next
        End While
        reader.Close()
        reader = Nothing
        mydb.Close()
        mydb.Dispose()

    End Sub
End Class

Last edited by Kayot; 06-21-2008 at 04:32 AM.. Reason: Always use code brackets, its the polite way to post code XD
Reply With Quote