Imports System.Data.OleDb
Imports System.IO

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents C1SchemaDef1 As C1.Data.C1SchemaDef
    Friend WithEvents C1DataSet1 As C1.Data.C1DataSet
    Friend WithEvents button1 As System.Windows.Forms.Button
    Friend WithEvents dataGrid1 As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.C1SchemaDef1 = New C1.Data.C1SchemaDef
        Me.C1DataSet1 = New C1.Data.C1DataSet
        Me.button1 = New System.Windows.Forms.Button
        Me.dataGrid1 = New System.Windows.Forms.DataGrid
        CType(Me.C1SchemaDef1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1DataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'C1SchemaDef1
        '
        Me.C1SchemaDef1.DataObjectsAssemblyFlags = CType((C1.Data.DataObjectsAssemblyFlags.DataSetNamespaces Or C1.Data.DataObjectsAssemblyFlags.StaticNameFields), C1.Data.DataObjectsAssemblyFlags)
        Me.C1SchemaDef1.DummyImage = CType(resources.GetObject("C1SchemaDef1.DummyImage"), System.Drawing.Bitmap)
        Me.C1SchemaDef1.SerializedSchemaXML = Me.C1SchemaDef1.GetSchemaFromResources(resources, "C1SchemaDef1", Me)
        Me.C1SchemaDef1.SerializedDesignTimeOptionsXML = Me.C1SchemaDef1.GetDesignTimeOptionsFromResources(resources, "C1SchemaDef1", Me)
        '
        'C1DataSet1
        '
        Me.C1DataSet1.BindingContextCtrl = Me
        Me.C1DataSet1.DataLibrary = ""
        Me.C1DataSet1.DataLibraryUrl = ""
        Me.C1DataSet1.DataSetDef = "DataSet"
        Me.C1DataSet1.Locale = New System.Globalization.CultureInfo("en-US")
        Me.C1DataSet1.Name = "C1DataSet1"
        Me.C1DataSet1.SchemaClassName = ""
        Me.C1DataSet1.SchemaDef = Me.C1SchemaDef1
        '
        'button1
        '
        Me.button1.Location = New System.Drawing.Point(368, 416)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(112, 23)
        Me.button1.TabIndex = 1
        Me.button1.Text = "Commit changes"
        '
        'dataGrid1
        '
        Me.dataGrid1.DataMember = "Customers"
        Me.dataGrid1.DataSource = Me.C1DataSet1
        Me.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dataGrid1.Location = New System.Drawing.Point(32, 16)
        Me.dataGrid1.Name = "dataGrid1"
        Me.dataGrid1.Size = New System.Drawing.Size(752, 376)
        Me.dataGrid1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(824, 461)
        Me.Controls.Add(Me.button1)
        Me.Controls.Add(Me.dataGrid1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.C1SchemaDef1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.C1DataSet1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        C1DataSet1.Update()
    End Sub

#Region " Switch to C1NWind.mdb database "

    Private Sub C1SchemaDef1_CreateSchema(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles C1SchemaDef1.CreateSchema

        Dim dbPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + _
            "\ComponentOne Samples\Common\C1NWind.mdb"
        If System.IO.File.Exists(dbPath) Then
            Dim conn As C1.Data.SchemaObjects.Connection = C1SchemaDef1.Schema.Connections(0)
            conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" + dbPath
        End If

    End Sub

#End Region

End Class
