Imports System.Reflection
Imports MySql.Data.MySqlClient
Public Class Patient
    Private con As MySqlConnection = mysqldb()
    Public output As Integer
    Public sql_string As String
    Private dt As DataTable = New DataTable
    Private cmd As MySqlCommand = New MySqlCommand
    Private da As MySqlDataAdapter = New MySqlDataAdapter
    Public field As String
    Public StrValue As Object

    Private attrib As Attribute

    Function executeQuery()
        With cmd
            .Connection = con
            .CommandText = setQuery
            'output = cmd.ExecuteNonQuery()
        End With
        da.SelectCommand = cmd
        da.Fill(dt)
        Return dt
    End Function


    ''   '  Function getFieldsOnOneTable(ByVal tbl_name As String)
    ''   '      Dim rows As Integer
    ''   '      Me.setQuery("DESC " & Me.tbl_name)
    ''   '      rows = Me.loadResultList()

    ''   '      Dim f = Array()
    ''   'for ( $x=0; $x<count( $rows ); $x++ ) {
    ''   '	f[] = $rows[$x]->Field
    ''   '}

    ''   '          Return f
    ''   '  End Function


    ''   Function loadResultList(ByVal key As String)
    ''       Dim cur As Integer
    ''       Dim array() As Array
    ''       cur = Me.executeQuery()

    ''       Dim row As Integer
    ''       da = New MySqlDataAdapter
    ''       da.SelectCommand = cmd
    ''       dt = New DataTable
    ''       da.Fill(dt)

    ''       For i = 0 To dt.Rows.Count - 1
    ''           array(i) = dt.Rows(0).Item(i)
    ''       Next

    ''       '       While  row =

    ''       '	while row = mysql_fetch_object( $cur )) {
    ''       '		if ($key) {
    ''       '			$array[$row->$key] = $row;
    ''       '		} else {
    ''       '			$array[] = $row;
    ''       '		}
    ''       '	}
    ''       '	mysql_free_result( $cur );
    ''       '	return $array;
    ''       '}
    ''   End Function
    ''   'Dim fullyQualifiedClassName As String = "System.Windows.Forms.TextBox"
    ''   '' Dim fullyQualifiedClassName As String = "System.Windows.Forms.Button"
    ''   'Dim o = fetchInstance(fullyQualifiedClassName)
    ''   '' sometime later where you can narrow down the type or interface...
    ''   'Dim b = CType(o, Control)
    ''   '        b.Text = "test"
    ''   '        b.Top = 10
    ''   '        b.Left = 10
    ''   '        Controls.Add(b)

    ''   Private Function fetchInstance(ByVal fullyQualifiedClassName As String) As Object
    ''       Dim nspc As String = fullyQualifiedClassName.Substring(0, fullyQualifiedClassName.LastIndexOf("."c))
    ''       Dim o As Object = Nothing
    ''       Try
    ''           For Each ay In Assembly.GetExecutingAssembly().GetReferencedAssemblies()
    ''               If (ay.Name = nspc) Then
    ''                   o = Assembly.Load(ay).CreateInstance(fullyQualifiedClassName)
    ''                   Exit For
    ''               End If
    ''           Next
    ''       Catch
    ''       End Try
    ''       Return o
    ''   End Function

    ''Private Function has_attribute(ByVal attribute)
    ''    'We don't care about the value, we just want to know if the key exists
    ''    'Will return true or false
    ''    Return KeyValuePair(attribute, attributes())()
    ''End Function
    ''   Protected Function attributes()
    ''       'return an array of attribute names and their values

    ''       Dim attribute() As Array

    ''  foreach($this->db_fields() as $field) {
    ''    if(property_exists($this, $field)) {
    ''		$attributes[$field] = $this->$field;
    ''	}
    ''  }
    ''  return $attributes;
    ''}
    ''   End Function


    'Private Function has_attribute(ByVal attrib As Attribute)
    '    Dim key As Integer
    '    'We don't care about the value, we just want to know if the key exists
    '    'Will return true or false

    'End Function
    Private Property fields() As String
        Get
            Return Me.field
        End Get
        Set(ByVal value As String)
            Me.field = value
        End Set
    End Property
 
    Private Property obj() As Object()
        Get
            Return Me.StrValue
        End Get
        Set(ByVal value As Object())
            Me.StrValue = value
        End Set
    End Property

    Property setQuery() As String
        Get
            Return Me.sql_string
        End Get
        Set(ByVal value As String)
            Me.sql_string = value
        End Set
    End Property

    'Private Function getFields(ByVal tbl_table As String)
    '    Dim row As Integer 
    'End Function
 
    Function create_Patient(ByVal field As String(), ByVal strArrayVal As String()) As Boolean
        Try
            con.Open()

            fields = Me.executeQuery()



        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Clone()
        End Try

        If output > 1 Then
            Return True
        Else
            Return False
        End If
    End Function
End Class
