Imports System.IO
Imports MySql.Data.MySqlClient

Module MySQL

    Public TAKEONE_EVENT As Integer     ' This Carries The Select Event Number

    Public Function CON_STRING() As String

        With My.Settings

            Return "server=" & .server & "; Port=" & .port & "; user id=" & .userid & "; password=" & .password & "; database=" & .database & ";"

        End With

    End Function

    Public Function CON_TEST(Server As String, Port As Integer, Database As String, UserName As String, Password As String) As Boolean

        Dim CON_TEST_STRING As String = "server=" & Server & "; Port=" & Port & "; user id=" & UserName & "; password=" & Password & "; database=" & Database & ";"
        Dim CON As New MySqlConnection(CON_TEST_STRING)

        Try
            CON.Open()
            CON.Close()
            'MessageBox.Show("Connection Sucessfull")
            Return True
        Catch ex As MySqlException
            'MessageBox.Show(ex.Message)
            Return False
        End Try

    End Function

    Public Function ReadMySQLDate(MySQLDate As String) As Date

        Dim dDate As Date = Date.ParseExact(MySQLDate, "yyyy-MM-dd", Globalization.CultureInfo.InvariantCulture)
        Return dDate

    End Function

    Public Function ReadMySQLDateTime(MySQLDateTime As String) As DateTime

        Dim dDate As DateTime = DateTime.ParseExact(MySQLDateTime, "yyyy-MM-dd hh:mm:ss", Globalization.CultureInfo.InvariantCulture)
        Return dDate

    End Function

End Module
