casper1985 0 Newbie Poster

Hi,

I have wrote the code below to connect to my database, i am using myphpadmin via wampserver.

Can anyone help create a record set to connect to the same database.

The below code is in a module, i would like the record set to be in the same or a different module.

Imports System.Data
Imports MySql.Data.MySqlClient

Module modConnection

    Public conn As New MySqlConnection

    Public Sub connectDatabase()

        Try
            If conn.State = ConnectionState.Closed Then
                conn.ConnectionString = "Data Source=localhost;Database=farmers;User ID=root;"
                conn.Open()
            End If

        Catch myerror As Exception
            MsgBox("Error in Database Connection", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")
        End Try

    End Sub

    Public Sub DiconnectDatabase()

        Try
            conn.Close()

        Catch myerror As MySql.Data.MySqlClient.MySqlException

        End Try
    End Sub


End Module

Thank you