windows

SQLServerデータ出力 VB.NET

SQLServerデータ出力 VB.NET

環境 Windows11_23H2 Visual Studio_2022 SQLServer_2022

起動画面 設定ファイルより既定値を取得します。LAN 内のサーバーを探索します(選択可能)。データベースの選択可能です。選択されたデータベース内のテーブルを表示します。テーブルをダブルクリックで選択します。

デフォルトで全項目選択です。項目を選択できます。選択条件を指定できます。データ出力順を指定できます。データ表示ボタンで内容確認ができます(最大50000行としました)。データ作成でcsvファイルと出力内容を定義ファイルとして作成します。定義読込は、定義ファイルに従って出力内容を再現します。

既定値を登録します。登録内容は、アプリ再起動後から有効になります。LAN検索は、on以外はサーバー検索しないので起動時間が短縮されます。

ソリューション構成

Module1

Imports System.Data.OleDb

Module Module1

    Public F1 As Form1

    Public fname As System.IO.StreamReader
    Public SYSTEM_NAME As String
    Public USER_NAME As String
    Public PASSWORD As String
    Public SYSTEM_NAME2 As String
    Public USER_NAME2 As String
    Public PASSWORD2 As String
    Public SERVER As String
    Public LIBL As String
    Public SEARCH As String

    Public F2Str As String

    Public n As Integer = FreeFile()

    Public tblname As String
    Public tblname2 As String
    Public TEIGIMEI As String

    Public tblnameINV As Long
    Public tblnameNAM As String

    Public CoString As String
    Public CoStringdb As String


    Public Sub INI()

        Try
            Dim stCurrentDir As String = System.IO.Directory.GetCurrentDirectory()
            n = FreeFile()
            FileOpen(n, stCurrentDir & "\PARA.ini", OpenMode.Input)
            SYSTEM_NAME = LineInput(n)
            USER_NAME = LineInput(n)
            PASSWORD = LineInput(n)
            SERVER = LineInput(n)
            LIBL = LineInput(n)
            SEARCH = LineInput(n)
            FileClose(n)
        Catch
            MsgBox("設定ファイルエラー:エラーNO:" &
            Err.Number & vbCr & Err.Description & vbCr &
            "基本設定してください。")

        End Try

        CoString = "Provider=SQLOLEDB.1;Data Source=" & SYSTEM_NAME _
                 & ";Initial Catalog=" & LIBL _
                 & ";Password=" & PASSWORD & ";User ID=" & USER_NAME & ";"

        CoStringdb = "Provider=SQLOLEDB.1;Data Source=" & SYSTEM_NAME _
                   & ";Initial Catalog=master" _
                   & ";Password=" & PASSWORD & ";User ID=" & USER_NAME & ";"


    End Sub


    Public Sub SHtblname(ByVal TempValue As String)

        Dim co As New OleDb.OleDbConnection
        Dim rs As OleDb.OleDbDataReader
        Dim cmd As New OleDb.OleDbCommand

        tblnameINV = 1
        tblnameNAM = "__"

        '***************************************
        '* 初期処理
        '***************************************
        Try

            co.ConnectionString = CoString

            co.Open()

            cmd.Connection() = co

            cmd.CommandText = "select * from tblname WHERE table_name=" & "'" & TempValue & "'"

            rs = cmd.ExecuteReader()

            While rs.Read()
                tblnameINV = 0
                tblnameNAM = rs.Item("table_text")
            End While

            rs.Close()

            '***************************************
            '* 終了処理
            '***************************************

            'co.Close()

        Catch ex As OleDbException

            Exit Sub
            'MsgBox("データベース接続エラーです。" & vbCr _
            '& ex.Message & vbCr _
            '& "続行します")
        End Try

    End Sub

End Module

Form1

Imports System.Data.OleDb
Imports System.Data.Sql
Imports System.Reflection
Imports System.Windows.Forms.VisualStyles.VisualStyleElement

Public Class Form1

    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

        If e.KeyChar = Chr(13) Then
            SendKeys.Send("{TAB}")
            e.Handled = True
        End If

    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim co As New OleDb.OleDbConnection
        Dim rs As OleDb.OleDbDataReader
        Dim cmd As New OleDb.OleDbCommand

        Me.KeyPreview = True

        INI()

        If SEARCH = "on" Then
            'ネットワーク上のSQLサーバーインスタンス取得
            Dim instance As SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance
            Dim tbl As DataTable = instance.GetDataSources()

            For Each row As DataRow In tbl.Rows

                'DBNullがある場合があるのでそれを防ぐ
                If row("ServerName") Is DBNull.Value Then
                    Continue For
                End If

                'コンボボックスにサーバー名を追加
                ComboBox1.Items.Add(row("ServerName").ToString)

            Next
        End If

        TextBox1.Text = SYSTEM_NAME
        TextBox2.Text = ""
        TextBox3.Text = ""

        ListView1.View = View.Details
        ListView1.Columns.Add("テーブル名", 200, HorizontalAlignment.Left)
        ListView1.Columns.Add("摘要", 300, HorizontalAlignment.Left)

        F1 = Me

        ListView1.Visible() = False

        Me.Cursor = Cursors.WaitCursor

        Dim W As Integer = ListView1.Width - 10
        ListView1.Items.Clear()

        Try

            '***************************************
            '* 初期処理
            '***************************************

            co.ConnectionString = CoStringdb

            co.Open()

            cmd = co.CreateCommand


            '***************************************
            '* データの取得
            '***************************************

            cmd.CommandText = "select * from sysdatabases" _
                            & " order by name"

            rs = cmd.ExecuteReader()

            ComboBox2.Items.Clear()

            While rs.Read()

                ComboBox2.Items.Add(rs.Item("name").ToString)

            End While

            rs.Close()

            co.Close()

        Catch ex As Exception

            'rs.Close()

            co.Close()

        End Try

        Try
            co.ConnectionString = CoString

            co.Open()

            cmd = co.CreateCommand


            cmd.CommandText = " select a.name as table_name " _
                            & " from sysobjects as a with(nolock)" _
                            & " where (a.type=" & "'" & "U" & "'" _
                            & " or a.type=" & "'" & "V" & "')" _
                            & " and a.status>=0" _
                            & " order by a.type,a.name"

            rs = cmd.ExecuteReader

            While rs.Read()
                SHtblname(rs.Item("table_name").ToString)
                Dim LV As New ListViewItem(rs.Item("table_name").ToString)
                LV.SubItems.Add(tblnameNAM)
                ListView1.Items.Add(LV)

            End While

            rs.Close()

            co.Close()

            '***************************************
            '* 終了処理
            '***************************************

        Catch ex As Exception

            co.Close()

        End Try

        Me.Cursor = Cursors.Arrow

        ListView1.Visible() = True
        ListView1.Focus()
        TextBox4.Text = LIBL

    End Sub

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

        If e.KeyCode = Keys.End Then
            End
        End If

    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        End

    End Sub
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

        If e.KeyCode = Keys.Enter Then

            If TextBox1.Text = "" Then
                MsgBox("SQLサーバーエラー")
                TextBox1.Focus()
            Else

            End If

        End If

    End Sub

    Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown

        If e.KeyCode = Keys.Enter Then

            If TextBox2.Text = "" Then
                MsgBox("ユーザーIDエラー")
                TextBox2.Focus()
            Else

            End If

        End If

    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged

        If ComboBox2.Text = "" Then

            Exit Sub

        End If

        If SYSTEM_NAME2 <> "" And USER_NAME2 <> "" And PASSWORD2 <> "" Then
            SYSTEM_NAME = SYSTEM_NAME2
            USER_NAME = USER_NAME2
            PASSWORD = PASSWORD2
        End If

        LIBL = ComboBox2.Text

        CoString = "Provider=SQLOLEDB.1;Data Source=" & SYSTEM_NAME _
                 & ";Initial Catalog=" & LIBL _
                 & ";Password=" & PASSWORD & ";User ID=" & USER_NAME & ";"

        Dim co As New OleDb.OleDbConnection
        Dim rs As OleDb.OleDbDataReader
        Dim cmd As New OleDb.OleDbCommand

        ListView1.Clear()

        ListView1.View = View.Details
        ListView1.Columns.Add("テーブル名", 200, HorizontalAlignment.Left)
        ListView1.Columns.Add("摘要", 300, HorizontalAlignment.Left)

        ListView1.Visible() = False

        Me.Cursor = Cursors.WaitCursor

        Dim W As Integer = ListView1.Width - 10
        ListView1.Items.Clear()

        '***************************************
        '* 初期処理
        '***************************************

        co.ConnectionString = CoString

        co.Open()

        cmd = co.CreateCommand

        '***************************************
        '* データの取得
        '***************************************

        cmd.CommandText = " select a.name as table_name " _
                            & " from sysobjects as a with(nolock)" _
                            & " where (a.type=" & "'" & "U" & "'" _
                            & " or a.type=" & "'" & "V" & "')" _
                            & " and a.status>=0" _
                            & " order by a.type,a.name"

        rs = cmd.ExecuteReader

        While rs.Read()
            SHtblname(rs.Item("table_name").ToString)
            Dim LV As New ListViewItem(rs.Item("table_name").ToString)
            LV.SubItems.Add(tblnameNAM)
            ListView1.Items.Add(LV)

        End While

        rs.Close()

        '***************************************
        '* 終了処理
        '***************************************

        Me.Cursor = Cursors.Arrow

        ListView1.Visible() = True
        ListView1.Focus()
        TextBox4.Text = LIBL

    End Sub

    Private Sub TextBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox3.KeyDown

        If e.KeyCode = Keys.Enter Then

            If TextBox3.Text = "" Then
                MsgBox("パスワードエラー")
                TextBox3.Focus()

            Else

                TextBox4.Text = ""
                Dim co As New OleDb.OleDbConnection
                Dim rs As OleDb.OleDbDataReader
                Dim cmd As New OleDb.OleDbCommand
                Dim COSTRING2 As String

                SYSTEM_NAME2 = TextBox1.Text
                USER_NAME2 = TextBox2.Text
                PASSWORD2 = TextBox3.Text

                COSTRING2 = "Provider=SQLOLEDB.1;Data Source=" & SYSTEM_NAME2 _
                          & ";Initial Catalog=master" _
                          & ";Password=" & PASSWORD2 & ";User ID=" & USER_NAME2 & ";"

                Try

                    co.ConnectionString = COSTRING2

                    co.Open()

                    '***************************************
                    '* データの取得
                    '***************************************

                    cmd.Connection() = co

                    cmd.CommandText = " select * from sysdatabases" _
                                    & " order by name"

                    rs = cmd.ExecuteReader()

                    ComboBox2.Items.Clear()

                    While rs.Read()

                        ComboBox2.Items.Add(rs.Item("name").ToString)

                    End While

                    '***************************************
                    '* 終了処理
                    '***************************************

                    co.Close()

                Catch ex As OleDbException
                    MsgBox(cmd.CommandText & "データベース接続エラーです。" & vbCr &
                           ex.Message & vbCr &
                           "再入力してください。")
                    Exit Sub
                    TextBox1.Focus()

                End Try

            End If

        End If

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        TextBox1.Text = ComboBox1.Text

        If TextBox1.Text <> "" Then
            TextBox2.Focus()
        Else
            Exit Sub
        End If

    End Sub


    Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick

        tblname = ListView1.FocusedItem.SubItems(0).Text
        tblname2 = ListView1.FocusedItem.SubItems(0).Text & "_" & ListView1.FocusedItem.SubItems(1).Text
        TEIGIMEI = ""

        Dim iform2 As New Form2
        iform2.ShowDialog()
        LISTSELECT()

    End Sub

    Private Sub ListView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown

        If e.KeyCode = Keys.Enter Then

            tblname = ListView1.FocusedItem.SubItems(0).Text
            tblname2 = ListView1.FocusedItem.SubItems(0).Text & "_" & ListView1.FocusedItem.SubItems(1).Text
            TEIGIMEI = ""

            Dim iform2 As New Form2
            iform2.ShowDialog()
            LISTSELECT()

        End If

    End Sub

    Private Sub LISTSELECT()

        Dim I As Integer
        Dim SELI As Integer

        For I = 1 To ListView1.Items.Count
            If ListView1.Items(I - 1).SubItems(0).Text = tblname Then
                SELI = I - 1
            End If
        Next

        '指定行を選択状態にする
        ListView1.Items(SELI).Selected = True
        ListView1.Select()  'ListView をアクティブにする
        ListView1.Focus()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim filename As String
        Dim ret As DialogResult
        Dim n4 As Integer = FreeFile()
        Dim str As String

        OpenFileDialog1.Filter = "項目定義ファイル|*.tig"
        ret = OpenFileDialog1.ShowDialog
        If ret <> DialogResult.Cancel Then
            filename = OpenFileDialog1.FileName
        Else
            MsgBox("取消しました。")
            Exit Sub
        End If

        If filename = "" Then
            MsgBox("取消しました。")
            Exit Sub
        End If

        TEIGIMEI = filename
        Dim iform2 As New Form2
        iform2.ShowDialog()
        LISTSELECT()

    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim iform4 As New Form4
        iform4.ShowDialog()

    End Sub
End Class

Form2

Imports System.Data.OleDb

Public Class Form2

    Dim itm As String
    Dim c1 As String
    Dim c2 As String
    Dim c3 As String
    Dim c4 As String
    Dim c5 As String
    Dim c6 As String
    Dim c7 As String
    Dim c8 As String
    Dim c9 As String
    Dim c10 As String
    Dim c11 As String
    Dim c12 As String
    Dim c13 As String
    Dim c14 As String
    Dim c15 As String
    Dim c16 As String
    Dim c17 As String
    Dim c18 As String
    Dim c19 As String
    Dim c20 As String
    Dim c21 As String
    Dim c22 As String
    Dim c23 As String
    Dim c24 As String
    Dim c25 As String
    Dim c26 As String
    Dim c27 As String
    Dim c28 As String
    Dim c29 As String
    Dim c30 As String
    Dim c31 As String
    Dim c32 As String
    Dim c33 As String
    Dim c34 As String
    Dim c35 As String
    Dim c36 As String
    Dim c37 As String
    Dim c38 As String
    Dim c39 As String
    Dim c40 As String
    Dim c41 As String
    Dim c42 As String
    Dim c43 As String
    Dim c44 As String
    Dim c45 As String
    Dim c46 As String
    Dim c47 As String
    Dim c48 As String
    Dim c49 As String
    Dim C50 As String
    Dim fldtype(9999) As String

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.Close()

    End Sub
    Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

        If e.KeyCode = Keys.End Then
            Me.Close()
        End If

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If lblselect.Text = "" Then
            MsgBox("選択項目が有りません。")
            Exit Sub
        End If

        Dim filename As String
        Dim filename2 As String
        Dim ret As DialogResult
        Dim n2 As Integer = FreeFile()
        Dim n3 As Integer = FreeFile()
        Dim st As String
        Dim t As Date
        t = Now

        SaveFileDialog1.FileName = tblname2 & "_" & Format(t, "yyyy") & Format(t, "MM") & Format(t, "dd") _
                                 & "_" & Format(t, "hh") & Format(t, "mm") & ".csv"

        ret = SaveFileDialog1.ShowDialog
        If ret <> DialogResult.Cancel Then
            filename = SaveFileDialog1.FileName
        Else
            MsgBox("取消しました。")
            Exit Sub
        End If

        If filename = "" Then
            filename = "c:\" & tblname & ".csv"
        End If

        filename2 = Replace(filename, ".csv", ".tig")

        If IO.File.Exists(filename2) Then
            Kill(filename2)
        End If

        FileOpen(n3, filename2, OpenMode.Output)
        'select
        st = "01_" & lblselect.Text
        PrintLine(n3, st)
        'where
        st = "02_" & lblwhere.Text
        PrintLine(n3, st)
        'order
        st = "03_" & lblorder.Text
        PrintLine(n3, st)
        'table
        st = "04_" & lbltable.Text
        PrintLine(n3, st)
        'table2
        st = "05_" & lbltable2.Text
        PrintLine(n3, st)
        'group
        st = "06_"
        PrintLine(n3, st)
        'sum
        st = "07_"
        PrintLine(n3, st)

        'where_1
        st = "11_" & c41
        PrintLine(n3, st)
        st = "12_" & c21
        PrintLine(n3, st)
        st = "13_" & c31
        PrintLine(n3, st)
        st = "14_" & TextBox1.Text
        PrintLine(n3, st)
        'where_2
        st = "15_" & c42
        PrintLine(n3, st)
        st = "16_" & c22
        PrintLine(n3, st)
        st = "17_" & c32
        PrintLine(n3, st)
        st = "18_" & TextBox2.Text
        PrintLine(n3, st)
        'where_3
        st = "19_" & c43
        PrintLine(n3, st)
        st = "20_" & c23
        PrintLine(n3, st)
        st = "21_" & c33
        PrintLine(n3, st)
        st = "22_" & TextBox3.Text
        PrintLine(n3, st)
        'where_4
        st = "23_" & c44
        PrintLine(n3, st)
        st = "24_" & c24
        PrintLine(n3, st)
        st = "25_" & c34
        PrintLine(n3, st)
        st = "26_" & TextBox4.Text
        PrintLine(n3, st)
        'where_5
        st = "27_" & c45
        PrintLine(n3, st)
        st = "28_" & c25
        PrintLine(n3, st)
        st = "29_" & c35
        PrintLine(n3, st)
        st = "30_" & TextBox5.Text
        PrintLine(n3, st)
        'where_6
        st = "31_" & c46
        PrintLine(n3, st)
        st = "32_" & c26
        PrintLine(n3, st)
        st = "33_" & c36
        PrintLine(n3, st)
        st = "34_" & TextBox6.Text
        PrintLine(n3, st)
        'where_7
        st = "35_" & c47
        PrintLine(n3, st)
        st = "36_" & c27
        PrintLine(n3, st)
        st = "37_" & c37
        PrintLine(n3, st)
        st = "38_" & TextBox7.Text
        PrintLine(n3, st)
        'where_8
        st = "39_" & c48
        PrintLine(n3, st)
        st = "40_" & c28
        PrintLine(n3, st)
        st = "41_" & c38
        PrintLine(n3, st)
        st = "42_" & TextBox8.Text
        PrintLine(n3, st)
        'where_9
        st = "43_" & c49
        PrintLine(n3, st)
        st = "44_" & c29
        PrintLine(n3, st)
        st = "45_" & c28
        PrintLine(n3, st)
        st = "46_" & TextBox9.Text
        PrintLine(n3, st)
        'where_10
        st = "47_" & C50
        PrintLine(n3, st)
        st = "48_" & c30
        PrintLine(n3, st)
        st = "49_" & c40
        PrintLine(n3, st)
        st = "50_" & TextBox10.Text
        PrintLine(n3, st)
        'order_1
        st = "51_" & c1
        PrintLine(n3, st)
        st = "52_" & c11
        PrintLine(n3, st)
        'order_2
        st = "53_" & c2
        PrintLine(n3, st)
        st = "54_" & c12
        PrintLine(n3, st)
        'order_3
        st = "55_" & c3
        PrintLine(n3, st)
        st = "56_" & c13
        PrintLine(n3, st)
        'order_4
        st = "57_" & c4
        PrintLine(n3, st)
        st = "58_" & c14
        PrintLine(n3, st)
        'order_5
        st = "59_" & c5
        PrintLine(n3, st)
        st = "60_" & c15
        PrintLine(n3, st)
        'order_6
        st = "61_" & c6
        PrintLine(n3, st)
        st = "62_" & c16
        PrintLine(n3, st)
        'order_7
        st = "63_" & c7
        PrintLine(n3, st)
        st = "64_" & c17
        PrintLine(n3, st)
        'order_8
        st = "65_" & c8
        PrintLine(n3, st)
        st = "66_" & c18
        PrintLine(n3, st)
        'order_9
        st = "67_" & c9
        PrintLine(n3, st)
        st = "68_" & c19
        PrintLine(n3, st)
        'order_10
        st = "69_" & c10
        PrintLine(n3, st)
        st = "70_" & c20
        PrintLine(n3, st)

        FileClose(n3)

        If IO.File.Exists(filename) Then
            Kill(filename)
        End If

        FileOpen(n2, filename, OpenMode.Output)

        Me.Cursor = Cursors.WaitCursor

        Dim co As New OleDb.OleDbConnection
        'Dim rs As OleDb.OleDbDataReader
        'Dim cmd As New OleDb.OleDbCommand
        Dim oleda As OleDb.OleDbDataAdapter
        Dim dtset As DataSet = New DataSet("tbl")
        Dim dttable As DataTable
        Dim dtcolumn As DataColumn
        Dim dtrow As DataRow

        Dim i As Integer
        Dim j As Integer

        '***************************************
        '* 初期処理
        '***************************************
        Try
            co.ConnectionString = CoString

            co.Open()

            '***************************************
            '* データの取得
            '***************************************

            st = lblselect.Text & " " & lblwhere.Text & " " & lblorder.Text

            oleda = New OleDb.OleDbDataAdapter(st, co)

            oleda.Fill(dtset, tblname)

            dttable = dtset.Tables(tblname)
            Dim strcol As String
            strcol = ""
            For i = 0 To dttable.Columns.Count - 1
                dtcolumn = dttable.Columns(i)
                fldtype(i) = dtcolumn.DataType.ToString
                If i = 0 Then
                    strcol = dtcolumn.ColumnName
                Else
                    strcol = strcol & "," & dtcolumn.ColumnName
                End If
            Next

            PrintLine(n2, strcol)

            strcol = ""

            For i = 0 To dttable.Rows.Count - 1

                For j = 0 To dttable.Columns.Count - 1

                    If j = 0 Then
                        If fldtype(j) <> "System.String" Then
                            strcol = dttable.Rows(i)(j)
                        Else
                            strcol = """" & dttable.Rows(i)(j) & """"
                        End If
                    Else
                        If fldtype(j) <> "System.String" Then
                            strcol = strcol & "," & dttable.Rows(i)(j)
                        Else
                            strcol = strcol & "," & """" & dttable.Rows(i)(j) & """"
                        End If
                    End If

                Next

                PrintLine(n2, strcol)
                strcol = ""

            Next

            '***************************************
            '* 終了処理
            '***************************************

            co.Close()

            FileClose(n2)

        Catch ex As OleDbException
            MsgBox(st & "データベース接続エラーです。" & vbCr &
                   ex.Message & vbCr &
                   "検索終了します。FORM LOAD")
            'Exit Sub
        End Try

        Me.Cursor = Cursors.Arrow

        MsgBox("出力終了しました。")

    End Sub

    Private Sub Form2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

        If e.KeyChar = Chr(13) Then
            SendKeys.Send("{TAB}")
            e.Handled = True
        End If

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If TEIGIMEI <> "" Then
            TEIGI(TEIGIMEI)
            Exit Sub
        End If

        Me.KeyPreview = True

        ListView1.View = View.Details

        ListView1.Columns.Add("項目名", 300, HorizontalAlignment.Left)
        ListView1.Columns.Add("データタイプ", 9999, HorizontalAlignment.Left)

        Dim co As New OleDb.OleDbConnection
        'Dim rs As OleDb.OleDbDataReader
        'Dim cmd As New OleDb.OleDbCommand
        Dim oleda As OleDb.OleDbDataAdapter
        Dim dtset As DataSet = New DataSet("tbl")
        Dim dttable As DataTable
        Dim dtcolumn As DataColumn
        Dim st As String
        Dim i As Integer

        ListView1.Items.Clear()
        ComboBox1.Items.Clear()
        ComboBox2.Items.Clear()
        ComboBox3.Items.Clear()
        ComboBox4.Items.Clear()
        ComboBox5.Items.Clear()
        ComboBox6.Items.Clear()
        ComboBox7.Items.Clear()
        ComboBox8.Items.Clear()
        ComboBox9.Items.Clear()
        ComboBox10.Items.Clear()
        ComboBox1.Items.Add("")
        ComboBox2.Items.Add("")
        ComboBox3.Items.Add("")
        ComboBox4.Items.Add("")
        ComboBox5.Items.Add("")
        ComboBox6.Items.Add("")
        ComboBox7.Items.Add("")
        ComboBox8.Items.Add("")
        ComboBox9.Items.Add("")
        ComboBox10.Items.Add("")
        ComboBox11.Items.Clear()
        ComboBox12.Items.Clear()
        ComboBox13.Items.Clear()
        ComboBox14.Items.Clear()
        ComboBox15.Items.Clear()
        ComboBox16.Items.Clear()
        ComboBox17.Items.Clear()
        ComboBox18.Items.Clear()
        ComboBox19.Items.Clear()
        ComboBox20.Items.Clear()
        ComboBox11.Items.Add("")
        ComboBox12.Items.Add("")
        ComboBox13.Items.Add("")
        ComboBox14.Items.Add("")
        ComboBox15.Items.Add("")
        ComboBox16.Items.Add("")
        ComboBox17.Items.Add("")
        ComboBox18.Items.Add("")
        ComboBox19.Items.Add("")
        ComboBox20.Items.Add("")
        ComboBox11.Items.Add("DESC")
        ComboBox12.Items.Add("DESC")
        ComboBox13.Items.Add("DESC")
        ComboBox14.Items.Add("DESC")
        ComboBox15.Items.Add("DESC")
        ComboBox16.Items.Add("DESC")
        ComboBox17.Items.Add("DESC")
        ComboBox18.Items.Add("DESC")
        ComboBox19.Items.Add("DESC")
        ComboBox20.Items.Add("DESC")
        ComboBox21.Items.Clear()
        ComboBox22.Items.Clear()
        ComboBox23.Items.Clear()
        ComboBox24.Items.Clear()
        ComboBox25.Items.Clear()
        ComboBox26.Items.Clear()
        ComboBox27.Items.Clear()
        ComboBox28.Items.Clear()
        ComboBox29.Items.Clear()
        ComboBox30.Items.Clear()
        ComboBox21.Items.Add("")
        ComboBox22.Items.Add("")
        ComboBox23.Items.Add("")
        ComboBox24.Items.Add("")
        ComboBox25.Items.Add("")
        ComboBox26.Items.Add("")
        ComboBox27.Items.Add("")
        ComboBox28.Items.Add("")
        ComboBox29.Items.Add("")
        ComboBox30.Items.Add("")
        ComboBox31.Items.Add("")
        ComboBox32.Items.Add("")
        ComboBox33.Items.Add("")
        ComboBox34.Items.Add("")
        ComboBox35.Items.Add("")
        ComboBox36.Items.Add("")
        ComboBox37.Items.Add("")
        ComboBox38.Items.Add("")
        ComboBox39.Items.Add("")
        ComboBox40.Items.Add("")
        ComboBox31.Items.Add("=")
        ComboBox32.Items.Add("=")
        ComboBox33.Items.Add("=")
        ComboBox34.Items.Add("=")
        ComboBox35.Items.Add("=")
        ComboBox36.Items.Add("=")
        ComboBox37.Items.Add("=")
        ComboBox38.Items.Add("=")
        ComboBox39.Items.Add("=")
        ComboBox40.Items.Add("=")
        ComboBox31.Items.Add(">=")
        ComboBox32.Items.Add(">=")
        ComboBox33.Items.Add(">=")
        ComboBox34.Items.Add(">=")
        ComboBox35.Items.Add(">=")
        ComboBox36.Items.Add(">=")
        ComboBox37.Items.Add(">=")
        ComboBox38.Items.Add(">=")
        ComboBox39.Items.Add(">=")
        ComboBox40.Items.Add(">=")
        ComboBox31.Items.Add("<=")
        ComboBox32.Items.Add("<=")
        ComboBox33.Items.Add("<=")
        ComboBox34.Items.Add("<=")
        ComboBox35.Items.Add("<=")
        ComboBox36.Items.Add("<=")
        ComboBox37.Items.Add("<=")
        ComboBox38.Items.Add("<=")
        ComboBox39.Items.Add("<=")
        ComboBox40.Items.Add("<=")
        ComboBox31.Items.Add("<>")
        ComboBox32.Items.Add("<>")
        ComboBox33.Items.Add("<>")
        ComboBox34.Items.Add("<>")
        ComboBox35.Items.Add("<>")
        ComboBox36.Items.Add("<>")
        ComboBox37.Items.Add("<>")
        ComboBox38.Items.Add("<>")
        ComboBox39.Items.Add("<>")
        ComboBox40.Items.Add("<>")
        ComboBox31.Items.Add(">")
        ComboBox32.Items.Add(">")
        ComboBox33.Items.Add(">")
        ComboBox34.Items.Add(">")
        ComboBox35.Items.Add(">")
        ComboBox36.Items.Add(">")
        ComboBox37.Items.Add(">")
        ComboBox38.Items.Add(">")
        ComboBox39.Items.Add(">")
        ComboBox40.Items.Add(">")
        ComboBox31.Items.Add("<")
        ComboBox32.Items.Add("<")
        ComboBox33.Items.Add("<")
        ComboBox34.Items.Add("<")
        ComboBox35.Items.Add("<")
        ComboBox36.Items.Add("<")
        ComboBox37.Items.Add("<")
        ComboBox38.Items.Add("<")
        ComboBox39.Items.Add("<")
        ComboBox40.Items.Add("<")
        ComboBox41.Items.Add("")
        ComboBox42.Items.Add("")
        ComboBox43.Items.Add("")
        ComboBox44.Items.Add("")
        ComboBox45.Items.Add("")
        ComboBox46.Items.Add("")
        ComboBox47.Items.Add("")
        ComboBox48.Items.Add("")
        ComboBox49.Items.Add("")
        ComboBox50.Items.Add("")
        ComboBox41.Items.Add("AND")
        ComboBox42.Items.Add("AND")
        ComboBox43.Items.Add("AND")
        ComboBox44.Items.Add("AND")
        ComboBox45.Items.Add("AND")
        ComboBox46.Items.Add("AND")
        ComboBox47.Items.Add("AND")
        ComboBox48.Items.Add("AND")
        ComboBox49.Items.Add("AND")
        ComboBox50.Items.Add("AND")
        ComboBox41.Items.Add("OR")
        ComboBox42.Items.Add("OR")
        ComboBox43.Items.Add("OR")
        ComboBox44.Items.Add("OR")
        ComboBox45.Items.Add("OR")
        ComboBox46.Items.Add("OR")
        ComboBox47.Items.Add("OR")
        ComboBox48.Items.Add("OR")
        ComboBox49.Items.Add("OR")
        ComboBox50.Items.Add("OR")
        ComboBox41.Items.Add("(")
        ComboBox42.Items.Add("(")
        ComboBox43.Items.Add("(")
        ComboBox44.Items.Add("(")
        ComboBox45.Items.Add("(")
        ComboBox46.Items.Add("(")
        ComboBox47.Items.Add("(")
        ComboBox48.Items.Add("(")
        ComboBox49.Items.Add("(")
        ComboBox50.Items.Add("(")
        ComboBox41.Items.Add(")")
        ComboBox42.Items.Add(")")
        ComboBox43.Items.Add(")")
        ComboBox44.Items.Add(")")
        ComboBox45.Items.Add(")")
        ComboBox46.Items.Add(")")
        ComboBox47.Items.Add(")")
        ComboBox48.Items.Add(")")
        ComboBox49.Items.Add(")")
        ComboBox50.Items.Add(")")
        ComboBox41.Items.Add("AND (")
        ComboBox42.Items.Add("AND (")
        ComboBox43.Items.Add("AND (")
        ComboBox44.Items.Add("AND (")
        ComboBox45.Items.Add("AND (")
        ComboBox46.Items.Add("AND (")
        ComboBox47.Items.Add("AND (")
        ComboBox48.Items.Add("AND (")
        ComboBox49.Items.Add("AND (")
        ComboBox50.Items.Add("AND (")
        ComboBox41.Items.Add("OR (")
        ComboBox42.Items.Add("OR (")
        ComboBox43.Items.Add("OR (")
        ComboBox44.Items.Add("OR (")
        ComboBox45.Items.Add("OR (")
        ComboBox46.Items.Add("OR (")
        ComboBox47.Items.Add("OR (")
        ComboBox48.Items.Add("OR (")
        ComboBox49.Items.Add("OR (")
        ComboBox50.Items.Add("OR (")
        ComboBox41.Items.Add(") OR")
        ComboBox42.Items.Add(") OR")
        ComboBox43.Items.Add(") OR")
        ComboBox44.Items.Add(") OR")
        ComboBox45.Items.Add(") OR")
        ComboBox46.Items.Add(") OR")
        ComboBox47.Items.Add(") OR")
        ComboBox48.Items.Add(") OR")
        ComboBox49.Items.Add(") OR")
        ComboBox50.Items.Add(") OR")
        ComboBox41.Items.Add(") AND")
        ComboBox42.Items.Add(") AND")
        ComboBox43.Items.Add(") AND")
        ComboBox44.Items.Add(") AND")
        ComboBox45.Items.Add(") AND")
        ComboBox46.Items.Add(") AND")
        ComboBox47.Items.Add(") AND")
        ComboBox48.Items.Add(") AND")
        ComboBox49.Items.Add(") AND")
        ComboBox50.Items.Add(") AND")
        ComboBox41.Items.Add(") OR (")
        ComboBox42.Items.Add(") OR (")
        ComboBox43.Items.Add(") OR (")
        ComboBox44.Items.Add(") OR (")
        ComboBox45.Items.Add(") OR (")
        ComboBox46.Items.Add(") OR (")
        ComboBox47.Items.Add(") OR (")
        ComboBox48.Items.Add(") OR (")
        ComboBox49.Items.Add(") OR (")
        ComboBox50.Items.Add(") OR (")
        ComboBox41.Items.Add(") AND (")
        ComboBox42.Items.Add(") AND (")
        ComboBox43.Items.Add(") AND (")
        ComboBox44.Items.Add(") AND (")
        ComboBox45.Items.Add(") AND (")
        ComboBox46.Items.Add(") AND (")
        ComboBox47.Items.Add(") AND (")
        ComboBox48.Items.Add(") AND (")
        ComboBox49.Items.Add(") AND (")
        ComboBox50.Items.Add(") AND (")

        '***************************************
        '* 初期処理
        '***************************************
        Try
            co.ConnectionString = CoString

            co.Open()

            '***************************************
            '* データの取得
            '***************************************

            st = " select top 1 * FROM " & tblname

            oleda = New OleDb.OleDbDataAdapter(st, co)

            oleda.Fill(dtset, tblname)

            dttable = dtset.Tables(tblname)

            For i = 0 To dttable.Columns.Count - 1
                dtcolumn = dttable.Columns(i)
                Dim LV As New ListViewItem(dtcolumn.ColumnName)
                LV.SubItems.Add(dtcolumn.DataType.ToString)
                ListView1.Items.Add(LV)
                ComboBox1.Items.Add(dtcolumn.ColumnName)
                ComboBox2.Items.Add(dtcolumn.ColumnName)
                ComboBox3.Items.Add(dtcolumn.ColumnName)
                ComboBox4.Items.Add(dtcolumn.ColumnName)
                ComboBox5.Items.Add(dtcolumn.ColumnName)
                ComboBox6.Items.Add(dtcolumn.ColumnName)
                ComboBox7.Items.Add(dtcolumn.ColumnName)
                ComboBox8.Items.Add(dtcolumn.ColumnName)
                ComboBox9.Items.Add(dtcolumn.ColumnName)
                ComboBox10.Items.Add(dtcolumn.ColumnName)
                If dtcolumn.DataType.ToString <> "System.String" Then
                    ComboBox21.Items.Add(dtcolumn.ColumnName)
                    ComboBox22.Items.Add(dtcolumn.ColumnName)
                    ComboBox23.Items.Add(dtcolumn.ColumnName)
                    ComboBox24.Items.Add(dtcolumn.ColumnName)
                    ComboBox25.Items.Add(dtcolumn.ColumnName)
                    ComboBox26.Items.Add(dtcolumn.ColumnName)
                    ComboBox27.Items.Add(dtcolumn.ColumnName)
                    ComboBox28.Items.Add(dtcolumn.ColumnName)
                    ComboBox29.Items.Add(dtcolumn.ColumnName)
                    ComboBox30.Items.Add(dtcolumn.ColumnName)
                End If
            Next

            '***************************************
            '* 終了処理
            '***************************************

            co.Close()

        Catch ex As OleDbException
            MsgBox(st & "データベース接続エラーです。" & vbCr &
                   ex.Message & vbCr &
                   "検索終了します。FORM LOAD")
            'Exit Sub
        End Try

        lbltable.Text = tblname
        lbltable2.Text = tblname2

        lblselect.Text = "select * from " & tblname

        itm = ""

    End Sub


    Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick

        ListView1.FocusedItem.Checked = "TRUE"

    End Sub

    Private Sub ListView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown

        If e.KeyCode = Keys.End Then

            Me.Close()

        End If

        If e.KeyCode = Keys.Escape Then

            Me.Close()

        End If

    End Sub

    Private Sub CHECKON()

        Dim I As Integer

        For I = 0 To ListView1.Items.Count - 1
            ListView1.Items(I).Checked = "TRUE"
        Next

    End Sub

    Private Sub CHECKOFF()

        Dim I As Integer

        For I = 0 To ListView1.Items.Count - 1
            ListView1.Items(I).Checked = "FALSE"
        Next

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        CHECKON()
        lblselect.Text = "select * from " & tblname
        itm = ""

    End Sub


    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        CHECKOFF()
        lblselect.Text = ""
        itm = ""

    End Sub

    Private Sub CRTSQL()

        Dim I As Integer

        itm = ""

        For I = 0 To ListView1.Items.Count - 1

            If ListView1.Items(I).Checked = "true" Then
                If I = 0 Then
                    itm = itm & ListView1.Items(I).SubItems(0).Text
                Else
                    itm = itm & "," & ListView1.Items(I).SubItems(0).Text
                End If
            End If

        Next
        If itm = "" Then
            itm = " * "
        End If

        lblselect.Text = "select " & itm & " from " & tblname

    End Sub

    Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click

        ListView1.FocusedItem.Checked = "TRUE"

        If itm = "" Then
            itm = itm & ListView1.FocusedItem.SubItems(0).Text
        Else
            itm = itm & "," & ListView1.FocusedItem.SubItems(0).Text
        End If

        lblselect.Text = "select " & itm & " from " & tblname

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        c1 = ComboBox1.Text
        order()

    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged

        c2 = ComboBox2.Text
        order()

    End Sub

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged

        c3 = ComboBox3.Text
        order()

    End Sub

    Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged

        c4 = ComboBox4.Text
        order()

    End Sub

    Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged
        c5 = ComboBox5.Text
        order()

    End Sub

    Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged

        c6 = ComboBox6.Text
        order()

    End Sub

    Private Sub ComboBox7_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox7.SelectedIndexChanged

        c7 = ComboBox7.Text
        order()

    End Sub

    Private Sub ComboBox8_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox8.SelectedIndexChanged

        c8 = ComboBox8.Text
        order()

    End Sub

    Private Sub ComboBox9_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox9.SelectedIndexChanged

        c9 = ComboBox9.Text
        order()

    End Sub

    Private Sub ComboBox10_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox10.SelectedIndexChanged

        c10 = ComboBox10.Text
        order()

    End Sub

    Private Sub ComboBox11_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox11.SelectedIndexChanged

        c11 = ComboBox11.Text
        order()

    End Sub

    Private Sub ComboBox12_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox12.SelectedIndexChanged

        c12 = ComboBox12.Text
        order()

    End Sub

    Private Sub ComboBox13_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox13.SelectedIndexChanged

        c13 = ComboBox13.Text
        order()

    End Sub

    Private Sub ComboBox14_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox14.SelectedIndexChanged

        c14 = ComboBox14.Text
        order()

    End Sub

    Private Sub ComboBox15_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox15.SelectedIndexChanged

        c15 = ComboBox15.Text
        order()

    End Sub

    Private Sub ComboBox16_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox16.SelectedIndexChanged

        c16 = ComboBox16.Text
        order()

    End Sub

    Private Sub ComboBox17_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox17.SelectedIndexChanged

        c17 = ComboBox17.Text
        order()

    End Sub

    Private Sub ComboBox18_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox18.SelectedIndexChanged

        c18 = ComboBox18.Text
        order()

    End Sub

    Private Sub ComboBox19_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox19.SelectedIndexChanged

        c19 = ComboBox19.Text
        order()

    End Sub

    Private Sub ComboBox20_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox20.SelectedIndexChanged

        c20 = ComboBox20.Text
        order()

    End Sub

    Private Sub ComboBox21_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox21.SelectedIndexChanged

        c21 = ComboBox21.Text
        where()

    End Sub

    Private Sub ComboBox22_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox22.SelectedIndexChanged

        c22 = ComboBox22.Text
        where()

    End Sub

    Private Sub ComboBox23_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox23.SelectedIndexChanged

        c23 = ComboBox23.Text
        where()

    End Sub

    Private Sub ComboBox24_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox24.SelectedIndexChanged

        c24 = ComboBox24.Text
        where()

    End Sub

    Private Sub ComboBox25_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox25.SelectedIndexChanged

        c25 = ComboBox25.Text
        where()

    End Sub

    Private Sub ComboBox26_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox26.SelectedIndexChanged

        c26 = ComboBox26.Text
        where()

    End Sub
    Private Sub ComboBox27_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox27.SelectedIndexChanged

        c27 = ComboBox27.Text
        where()

    End Sub

    Private Sub ComboBox28_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox28.SelectedIndexChanged

        c28 = ComboBox28.Text
        where()

    End Sub

    Private Sub ComboBox29_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox29.SelectedIndexChanged

        c29 = ComboBox29.Text
        where()

    End Sub

    Private Sub ComboBox30_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox30.SelectedIndexChanged

        c30 = ComboBox30.Text
        where()

    End Sub

    Private Sub ComboBox31_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox31.SelectedIndexChanged

        c31 = ComboBox31.Text
        where()

    End Sub

    Private Sub ComboBox32_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox32.SelectedIndexChanged

        c32 = ComboBox32.Text
        where()

    End Sub

    Private Sub ComboBox33_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox33.SelectedIndexChanged

        c33 = ComboBox33.Text
        where()

    End Sub

    Private Sub ComboBox34_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox34.SelectedIndexChanged

        c34 = ComboBox34.Text
        where()

    End Sub

    Private Sub ComboBox35_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox35.SelectedIndexChanged

        c35 = ComboBox35.Text
        where()

    End Sub

    Private Sub ComboBox36_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox36.SelectedIndexChanged

        c36 = ComboBox36.Text
        where()

    End Sub
    Private Sub ComboBox37_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox37.SelectedIndexChanged

        c37 = ComboBox37.Text
        where()

    End Sub

    Private Sub ComboBox38_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox38.SelectedIndexChanged

        c38 = ComboBox38.Text
        where()

    End Sub

    Private Sub ComboBox39_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox39.SelectedIndexChanged

        c39 = ComboBox39.Text
        where()

    End Sub

    Private Sub ComboBox40_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox40.SelectedIndexChanged

        c40 = ComboBox40.Text
        where()

    End Sub
    Private Sub ComboBox41_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox41.SelectedIndexChanged

        c41 = ComboBox41.Text
        where()

    End Sub

    Private Sub ComboBox42_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox42.SelectedIndexChanged

        c42 = ComboBox42.Text
        where()

    End Sub

    Private Sub ComboBox43_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox43.SelectedIndexChanged

        c43 = ComboBox43.Text
        where()

    End Sub

    Private Sub ComboBox44_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox44.SelectedIndexChanged

        c44 = ComboBox44.Text
        where()

    End Sub

    Private Sub ComboBox45_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox45.SelectedIndexChanged

        c45 = ComboBox45.Text
        where()

    End Sub

    Private Sub ComboBox46_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox46.SelectedIndexChanged

        c46 = ComboBox46.Text
        where()

    End Sub

    Private Sub ComboBox47_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox47.SelectedIndexChanged

        c47 = ComboBox47.Text
        where()

    End Sub

    Private Sub ComboBox48_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox48.SelectedIndexChanged

        c48 = ComboBox48.Text
        where()

    End Sub

    Private Sub ComboBox49_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox49.SelectedIndexChanged

        c49 = ComboBox49.Text
        where()

    End Sub

    Private Sub ComboBox50_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox50.SelectedIndexChanged

        C50 = ComboBox50.Text
        where()

    End Sub

    Private Sub order()

        Dim fst As Integer
        fst = 0
        lblorder.Text = ""

        If c1 <> "" Or c2 <> "" Or c3 <> "" Or c4 <> "" Or c5 <> "" _
          Or c6 <> "" Or c7 <> "" Or c8 <> "" Or c9 <> "" Or c10 <> "" Then
            If c1 <> "" Then
                lblorder.Text = "Order By " & c1 & " " & c11
                fst = 1
            End If
            If c2 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c2 & " " & c12
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c2 & " " & c12
                End If
            End If
            If c3 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c3 & " " & c13
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c3 & " " & c13
                End If
            End If
            If c4 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c4 & " " & c14
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c4 & " " & c14
                End If
            End If
            If c5 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c5 & " " & c15
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c5 & " " & c15
                End If
            End If
            If c6 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c6 & " " & c16
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c6 & " " & c16
                End If
            End If
            If c7 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c7 & " " & c17
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c7 & " " & c17
                End If
            End If
            If c8 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c8 & " " & c18
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c8 & " " & c18
                End If
            End If
            If c9 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c9 & " " & c19
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c9 & " " & c19
                End If
            End If
            If c10 <> "" Then
                If fst = 0 Then
                    lblorder.Text = "Order By " & c10 & " " & c20
                    fst = 1
                Else
                    lblorder.Text = lblorder.Text & "," & c10 & " " & c20
                End If
            End If
        End If

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        ComboBox1.Text = ""
        ComboBox2.Text = ""
        ComboBox3.Text = ""
        ComboBox4.Text = ""
        ComboBox5.Text = ""
        ComboBox6.Text = ""
        ComboBox7.Text = ""
        ComboBox8.Text = ""
        ComboBox9.Text = ""
        ComboBox10.Text = ""

        ComboBox11.Text = ""
        ComboBox12.Text = ""
        ComboBox13.Text = ""
        ComboBox14.Text = ""
        ComboBox15.Text = ""
        ComboBox16.Text = ""
        ComboBox17.Text = ""
        ComboBox18.Text = ""
        ComboBox19.Text = ""
        ComboBox20.Text = ""

        c1 = ""
        c2 = ""
        c3 = ""
        c4 = ""
        c5 = ""
        c6 = ""
        c7 = ""
        c8 = ""
        c9 = ""
        c10 = ""

        c11 = ""
        c12 = ""
        c13 = ""
        c14 = ""
        c15 = ""
        c16 = ""
        c17 = ""
        c18 = ""
        c19 = ""
        c20 = ""

        lblorder.Text = ""

    End Sub

    Private Sub where()

        lblwhere.Text = ""
        If c21 <> "" And c31 <> "" Then
            lblwhere.Text = "Where " & " " & c41 & " " & c21 & c31 & TextBox1.Text
            If (c42 <> "" And c22 <> "" And c32 <> "") Or c42 = ")" Then
                If c22 <> "" Then
                    lblwhere.Text = lblwhere.Text & " " & c42 & " " & c22 & c32 & TextBox2.Text
                Else
                    lblwhere.Text = lblwhere.Text & " " & c42
                End If
                If (c43 <> "" And c23 <> "" And c33 <> "") Or c43 = ")" Then
                    If c23 <> "" Then
                        lblwhere.Text = lblwhere.Text & " " & c43 & " " & c23 & c33 & TextBox3.Text
                    Else
                        lblwhere.Text = lblwhere.Text & " " & c43
                    End If
                    If (c44 <> "" And c24 <> "" And c34 <> "") Or c44 = ")" Then
                        If c24 <> "" Then
                            lblwhere.Text = lblwhere.Text & " " & c44 & " " & c24 & c34 & TextBox4.Text
                        Else
                            lblwhere.Text = lblwhere.Text & " " & c44
                        End If
                        If (c45 <> "" And c25 <> "" And c35 <> "") Or c45 = ")" Then
                            If c25 <> "" Then
                                lblwhere.Text = lblwhere.Text & " " & c45 & " " & c25 & c35 & TextBox5.Text
                            Else
                                lblwhere.Text = lblwhere.Text & " " & c45
                            End If
                            If (c46 <> "" And c26 <> "" And c36 <> "") Or c46 = ")" Then
                                If c26 <> "" Then
                                    lblwhere.Text = lblwhere.Text & " " & c46 & " " & c26 & c36 & TextBox6.Text
                                Else
                                    lblwhere.Text = lblwhere.Text & " " & c46
                                End If
                                If (c47 <> "" And c27 <> "" And c37 <> "") Or c47 = ")" Then
                                    If c27 <> "" Then
                                        lblwhere.Text = lblwhere.Text & " " & c47 & " " & c27 & c37 & TextBox7.Text
                                    Else
                                        lblwhere.Text = lblwhere.Text & " " & c47
                                    End If
                                    If (c48 <> "" And c28 <> "" And c38 <> "") Or c48 = ")" Then
                                        If c28 <> "" Then
                                            lblwhere.Text = lblwhere.Text & " " & c48 & " " & c28 & c38 & TextBox8.Text
                                        Else
                                            lblwhere.Text = lblwhere.Text & " " & c48
                                        End If
                                        If (c49 <> "" And c29 <> "" And c39 <> "") Or c49 = ")" Then
                                            If c29 <> "" Then
                                                lblwhere.Text = lblwhere.Text & " " & c49 & " " & c29 & c39 & TextBox9.Text
                                            Else
                                                lblwhere.Text = lblwhere.Text & " " & c49
                                            End If
                                            If (C50 <> "" And c30 <> "" And c40 <> "") Or C50 = ")" Then
                                                If c30 <> "" Then
                                                    lblwhere.Text = lblwhere.Text & " " & C50 & " " & c30 & c40 & TextBox10.Text
                                                Else
                                                    lblwhere.Text = lblwhere.Text & " " & C50
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If

    End Sub

    Private Sub TextBox1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        where()

    End Sub

    Private Sub TextBox2_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

        where()

    End Sub

    Private Sub TextBox3_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

        where()

    End Sub

    Private Sub TextBox4_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged

        where()

    End Sub

    Private Sub TextBox5_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged

        where()

    End Sub

    Private Sub TextBox6_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        where()

    End Sub

    Private Sub TextBox7_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged

        where()

    End Sub

    Private Sub TextBox8_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged

        where()

    End Sub

    Private Sub TextBox9_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged

        where()

    End Sub

    Private Sub TextBox10_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged

        where()

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        ComboBox21.Text = ""
        ComboBox22.Text = ""
        ComboBox23.Text = ""
        ComboBox24.Text = ""
        ComboBox25.Text = ""
        ComboBox26.Text = ""
        ComboBox27.Text = ""
        ComboBox28.Text = ""
        ComboBox29.Text = ""
        ComboBox30.Text = ""

        ComboBox31.Text = ""
        ComboBox32.Text = ""
        ComboBox33.Text = ""
        ComboBox34.Text = ""
        ComboBox35.Text = ""
        ComboBox36.Text = ""
        ComboBox37.Text = ""
        ComboBox38.Text = ""
        ComboBox39.Text = ""
        ComboBox40.Text = ""

        ComboBox41.Text = ""
        ComboBox42.Text = ""
        ComboBox43.Text = ""
        ComboBox44.Text = ""
        ComboBox45.Text = ""
        ComboBox46.Text = ""
        ComboBox47.Text = ""
        ComboBox48.Text = ""
        ComboBox49.Text = ""
        ComboBox50.Text = ""

        c21 = ""
        c22 = ""
        c23 = ""
        c24 = ""
        c25 = ""
        c26 = ""
        c27 = ""
        c28 = ""
        c29 = ""
        c30 = ""

        c31 = ""
        c32 = ""
        c33 = ""
        c34 = ""
        c35 = ""
        c36 = ""
        c37 = ""
        c38 = ""
        c39 = ""
        c40 = ""

        c41 = ""
        c42 = ""
        c43 = ""
        c44 = ""
        c45 = ""
        c46 = ""
        c47 = ""
        c48 = ""
        c49 = ""
        C50 = ""

        TextBox1.Text = 0
        TextBox2.Text = 0
        TextBox3.Text = 0
        TextBox4.Text = 0
        TextBox5.Text = 0
        TextBox6.Text = 0
        TextBox7.Text = 0
        TextBox8.Text = 0
        TextBox9.Text = 0
        TextBox10.Text = 0

        lblwhere.Text = ""

    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        Dim filename As String
        Dim ret As DialogResult
        Dim n4 As Integer = FreeFile()
        Dim str As String

        OpenFileDialog1.Filter = "項目定義ファイル|*.tig"
        ret = OpenFileDialog1.ShowDialog
        If ret <> DialogResult.Cancel Then
            filename = OpenFileDialog1.FileName
        Else
            MsgBox("取消しました。")
            Exit Sub
        End If

        If filename = "" Then
            MsgBox("取消しました。")
            Exit Sub
        End If

        TEIGI(filename)

    End Sub

    Private Sub TEIGI(ByVal TEMP As String)

        Dim filename As String
        Dim ret As DialogResult
        Dim n4 As Integer = FreeFile()
        Dim str As String

        filename = TEMP

        Try
            FileOpen(n4, filename, OpenMode.Input)

            str = LineInput(n4)
            lblselect.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lblwhere.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lblorder.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lbltable.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lbltable2.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            '

            str = LineInput(n4)
            '

            tblname = lbltable.Text
            tblname2 = lbltable2.Text
            FileClose(n4)

        Catch
            MsgBox("定義ファイルエラー:エラーNO:" &
            Err.Number & vbCr & Err.Description & vbCr &
            "終了します。")
            End
        End Try

        Me.KeyPreview = True

        ListView1.View = View.Details

        ListView1.Columns.Add("項目名", 300, HorizontalAlignment.Left)
        ListView1.Columns.Add("データタイプ", 9999, HorizontalAlignment.Left)

        Dim co As New OleDb.OleDbConnection
        'Dim rs As OleDb.OleDbDataReader
        'Dim cmd As New OleDb.OleDbCommand
        Dim oleda As OleDb.OleDbDataAdapter
        Dim dtset As DataSet = New DataSet("tbl")
        Dim dttable As DataTable
        Dim dtcolumn As DataColumn
        Dim st As String
        Dim i As Integer

        ListView1.Items.Clear()
        ComboBox1.Items.Clear()
        ComboBox2.Items.Clear()
        ComboBox3.Items.Clear()
        ComboBox4.Items.Clear()
        ComboBox5.Items.Clear()
        ComboBox6.Items.Clear()
        ComboBox7.Items.Clear()
        ComboBox8.Items.Clear()
        ComboBox9.Items.Clear()
        ComboBox10.Items.Clear()
        ComboBox1.Items.Add("")
        ComboBox2.Items.Add("")
        ComboBox3.Items.Add("")
        ComboBox4.Items.Add("")
        ComboBox5.Items.Add("")
        ComboBox6.Items.Add("")
        ComboBox7.Items.Add("")
        ComboBox8.Items.Add("")
        ComboBox9.Items.Add("")
        ComboBox10.Items.Add("")
        ComboBox11.Items.Clear()
        ComboBox12.Items.Clear()
        ComboBox13.Items.Clear()
        ComboBox14.Items.Clear()
        ComboBox15.Items.Clear()
        ComboBox16.Items.Clear()
        ComboBox17.Items.Clear()
        ComboBox18.Items.Clear()
        ComboBox19.Items.Clear()
        ComboBox20.Items.Clear()
        ComboBox11.Items.Add("")
        ComboBox12.Items.Add("")
        ComboBox13.Items.Add("")
        ComboBox14.Items.Add("")
        ComboBox15.Items.Add("")
        ComboBox16.Items.Add("")
        ComboBox17.Items.Add("")
        ComboBox18.Items.Add("")
        ComboBox19.Items.Add("")
        ComboBox20.Items.Add("")
        ComboBox11.Items.Add("DESC")
        ComboBox12.Items.Add("DESC")
        ComboBox13.Items.Add("DESC")
        ComboBox14.Items.Add("DESC")
        ComboBox15.Items.Add("DESC")
        ComboBox16.Items.Add("DESC")
        ComboBox17.Items.Add("DESC")
        ComboBox18.Items.Add("DESC")
        ComboBox19.Items.Add("DESC")
        ComboBox20.Items.Add("DESC")
        ComboBox21.Items.Clear()
        ComboBox22.Items.Clear()
        ComboBox23.Items.Clear()
        ComboBox24.Items.Clear()
        ComboBox25.Items.Clear()
        ComboBox26.Items.Clear()
        ComboBox27.Items.Clear()
        ComboBox28.Items.Clear()
        ComboBox29.Items.Clear()
        ComboBox30.Items.Clear()
        ComboBox21.Items.Add("")
        ComboBox22.Items.Add("")
        ComboBox23.Items.Add("")
        ComboBox24.Items.Add("")
        ComboBox25.Items.Add("")
        ComboBox26.Items.Add("")
        ComboBox27.Items.Add("")
        ComboBox28.Items.Add("")
        ComboBox29.Items.Add("")
        ComboBox30.Items.Add("")
        ComboBox31.Items.Add("")
        ComboBox32.Items.Add("")
        ComboBox33.Items.Add("")
        ComboBox34.Items.Add("")
        ComboBox35.Items.Add("")
        ComboBox36.Items.Add("")
        ComboBox37.Items.Add("")
        ComboBox38.Items.Add("")
        ComboBox39.Items.Add("")
        ComboBox40.Items.Add("")
        ComboBox31.Items.Add("=")
        ComboBox32.Items.Add("=")
        ComboBox33.Items.Add("=")
        ComboBox34.Items.Add("=")
        ComboBox35.Items.Add("=")
        ComboBox36.Items.Add("=")
        ComboBox37.Items.Add("=")
        ComboBox38.Items.Add("=")
        ComboBox39.Items.Add("=")
        ComboBox40.Items.Add("=")
        ComboBox31.Items.Add(">=")
        ComboBox32.Items.Add(">=")
        ComboBox33.Items.Add(">=")
        ComboBox34.Items.Add(">=")
        ComboBox35.Items.Add(">=")
        ComboBox36.Items.Add(">=")
        ComboBox37.Items.Add(">=")
        ComboBox38.Items.Add(">=")
        ComboBox39.Items.Add(">=")
        ComboBox40.Items.Add(">=")
        ComboBox31.Items.Add("<=")
        ComboBox32.Items.Add("<=")
        ComboBox33.Items.Add("<=")
        ComboBox34.Items.Add("<=")
        ComboBox35.Items.Add("<=")
        ComboBox36.Items.Add("<=")
        ComboBox37.Items.Add("<=")
        ComboBox38.Items.Add("<=")
        ComboBox39.Items.Add("<=")
        ComboBox40.Items.Add("<=")
        ComboBox31.Items.Add("<>")
        ComboBox32.Items.Add("<>")
        ComboBox33.Items.Add("<>")
        ComboBox34.Items.Add("<>")
        ComboBox35.Items.Add("<>")
        ComboBox36.Items.Add("<>")
        ComboBox37.Items.Add("<>")
        ComboBox38.Items.Add("<>")
        ComboBox39.Items.Add("<>")
        ComboBox40.Items.Add("<>")
        ComboBox31.Items.Add(">")
        ComboBox32.Items.Add(">")
        ComboBox33.Items.Add(">")
        ComboBox34.Items.Add(">")
        ComboBox35.Items.Add(">")
        ComboBox36.Items.Add(">")
        ComboBox37.Items.Add(">")
        ComboBox38.Items.Add(">")
        ComboBox39.Items.Add(">")
        ComboBox40.Items.Add(">")
        ComboBox31.Items.Add("<")
        ComboBox32.Items.Add("<")
        ComboBox33.Items.Add("<")
        ComboBox34.Items.Add("<")
        ComboBox35.Items.Add("<")
        ComboBox36.Items.Add("<")
        ComboBox37.Items.Add("<")
        ComboBox38.Items.Add("<")
        ComboBox39.Items.Add("<")
        ComboBox40.Items.Add("<")
        ComboBox41.Items.Add("")
        ComboBox42.Items.Add("")
        ComboBox43.Items.Add("")
        ComboBox44.Items.Add("")
        ComboBox45.Items.Add("")
        ComboBox46.Items.Add("")
        ComboBox47.Items.Add("")
        ComboBox48.Items.Add("")
        ComboBox49.Items.Add("")
        ComboBox50.Items.Add("")
        ComboBox41.Items.Add("AND")
        ComboBox42.Items.Add("AND")
        ComboBox43.Items.Add("AND")
        ComboBox44.Items.Add("AND")
        ComboBox45.Items.Add("AND")
        ComboBox46.Items.Add("AND")
        ComboBox47.Items.Add("AND")
        ComboBox48.Items.Add("AND")
        ComboBox49.Items.Add("AND")
        ComboBox50.Items.Add("AND")
        ComboBox41.Items.Add("OR")
        ComboBox42.Items.Add("OR")
        ComboBox43.Items.Add("OR")
        ComboBox44.Items.Add("OR")
        ComboBox45.Items.Add("OR")
        ComboBox46.Items.Add("OR")
        ComboBox47.Items.Add("OR")
        ComboBox48.Items.Add("OR")
        ComboBox49.Items.Add("OR")
        ComboBox50.Items.Add("OR")
        ComboBox41.Items.Add("(")
        ComboBox42.Items.Add("(")
        ComboBox43.Items.Add("(")
        ComboBox44.Items.Add("(")
        ComboBox45.Items.Add("(")
        ComboBox46.Items.Add("(")
        ComboBox47.Items.Add("(")
        ComboBox48.Items.Add("(")
        ComboBox49.Items.Add("(")
        ComboBox50.Items.Add("(")
        ComboBox41.Items.Add(")")
        ComboBox42.Items.Add(")")
        ComboBox43.Items.Add(")")
        ComboBox44.Items.Add(")")
        ComboBox45.Items.Add(")")
        ComboBox46.Items.Add(")")
        ComboBox47.Items.Add(")")
        ComboBox48.Items.Add(")")
        ComboBox49.Items.Add(")")
        ComboBox50.Items.Add(")")
        ComboBox41.Items.Add("AND (")
        ComboBox42.Items.Add("AND (")
        ComboBox43.Items.Add("AND (")
        ComboBox44.Items.Add("AND (")
        ComboBox45.Items.Add("AND (")
        ComboBox46.Items.Add("AND (")
        ComboBox47.Items.Add("AND (")
        ComboBox48.Items.Add("AND (")
        ComboBox49.Items.Add("AND (")
        ComboBox50.Items.Add("AND (")
        ComboBox41.Items.Add("OR (")
        ComboBox42.Items.Add("OR (")
        ComboBox43.Items.Add("OR (")
        ComboBox44.Items.Add("OR (")
        ComboBox45.Items.Add("OR (")
        ComboBox46.Items.Add("OR (")
        ComboBox47.Items.Add("OR (")
        ComboBox48.Items.Add("OR (")
        ComboBox49.Items.Add("OR (")
        ComboBox50.Items.Add("OR (")
        ComboBox41.Items.Add(") OR")
        ComboBox42.Items.Add(") OR")
        ComboBox43.Items.Add(") OR")
        ComboBox44.Items.Add(") OR")
        ComboBox45.Items.Add(") OR")
        ComboBox46.Items.Add(") OR")
        ComboBox47.Items.Add(") OR")
        ComboBox48.Items.Add(") OR")
        ComboBox49.Items.Add(") OR")
        ComboBox50.Items.Add(") OR")
        ComboBox41.Items.Add(") AND")
        ComboBox42.Items.Add(") AND")
        ComboBox43.Items.Add(") AND")
        ComboBox44.Items.Add(") AND")
        ComboBox45.Items.Add(") AND")
        ComboBox46.Items.Add(") AND")
        ComboBox47.Items.Add(") AND")
        ComboBox48.Items.Add(") AND")
        ComboBox49.Items.Add(") AND")
        ComboBox50.Items.Add(") AND")
        ComboBox41.Items.Add(") OR (")
        ComboBox42.Items.Add(") OR (")
        ComboBox43.Items.Add(") OR (")
        ComboBox44.Items.Add(") OR (")
        ComboBox45.Items.Add(") OR (")
        ComboBox46.Items.Add(") OR (")
        ComboBox47.Items.Add(") OR (")
        ComboBox48.Items.Add(") OR (")
        ComboBox49.Items.Add(") OR (")
        ComboBox50.Items.Add(") OR (")
        ComboBox41.Items.Add(") AND (")
        ComboBox42.Items.Add(") AND (")
        ComboBox43.Items.Add(") AND (")
        ComboBox44.Items.Add(") AND (")
        ComboBox45.Items.Add(") AND (")
        ComboBox46.Items.Add(") AND (")
        ComboBox47.Items.Add(") AND (")
        ComboBox48.Items.Add(") AND (")
        ComboBox49.Items.Add(") AND (")
        ComboBox50.Items.Add(") AND (")

        '***************************************
        '* 初期処理
        '***************************************
        Try
            co.ConnectionString = CoString

            co.Open()

            '***************************************
            '* データの取得
            '***************************************

            st = " select * FROM " & tblname

            oleda = New OleDb.OleDbDataAdapter(st, co)

            oleda.Fill(dtset, tblname)

            dttable = dtset.Tables(tblname)

            For i = 0 To dttable.Columns.Count - 1
                dtcolumn = dttable.Columns(i)
                Dim LV As New ListViewItem(dtcolumn.ColumnName)
                LV.SubItems.Add(dtcolumn.DataType.ToString)
                ListView1.Items.Add(LV)
                ComboBox1.Items.Add(dtcolumn.ColumnName)
                ComboBox2.Items.Add(dtcolumn.ColumnName)
                ComboBox3.Items.Add(dtcolumn.ColumnName)
                ComboBox4.Items.Add(dtcolumn.ColumnName)
                ComboBox5.Items.Add(dtcolumn.ColumnName)
                ComboBox6.Items.Add(dtcolumn.ColumnName)
                ComboBox7.Items.Add(dtcolumn.ColumnName)
                ComboBox8.Items.Add(dtcolumn.ColumnName)
                ComboBox9.Items.Add(dtcolumn.ColumnName)
                ComboBox10.Items.Add(dtcolumn.ColumnName)
                If dtcolumn.DataType.ToString <> "System.String" Then
                    ComboBox21.Items.Add(dtcolumn.ColumnName)
                    ComboBox22.Items.Add(dtcolumn.ColumnName)
                    ComboBox23.Items.Add(dtcolumn.ColumnName)
                    ComboBox24.Items.Add(dtcolumn.ColumnName)
                    ComboBox25.Items.Add(dtcolumn.ColumnName)
                    ComboBox26.Items.Add(dtcolumn.ColumnName)
                    ComboBox27.Items.Add(dtcolumn.ColumnName)
                    ComboBox28.Items.Add(dtcolumn.ColumnName)
                    ComboBox29.Items.Add(dtcolumn.ColumnName)
                    ComboBox30.Items.Add(dtcolumn.ColumnName)
                End If
            Next

            '***************************************
            '* 終了処理
            '***************************************

            co.Close()

        Catch ex As OleDbException
            MsgBox(st & "データベース接続エラーです。" & vbCr &
                   ex.Message & vbCr &
                   "検索終了します。FORM LOAD")
            'Exit Sub
        End Try

        Try
            FileOpen(n4, filename, OpenMode.Input)

            str = LineInput(n4)
            lblselect.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lblwhere.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lblorder.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lbltable.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            lbltable2.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            '

            str = LineInput(n4)
            '

            tblname = lbltable.Text
            tblname2 = lbltable2.Text

            str = LineInput(n4)
            ComboBox41.Text = Mid(str, 4, 9999)
            c41 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox21.Text = Mid(str, 4, 9999)
            c21 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox31.Text = Mid(str, 4, 9999)
            c31 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox1.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox42.Text = Mid(str, 4, 9999)
            c42 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox22.Text = Mid(str, 4, 9999)
            c22 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox32.Text = Mid(str, 4, 9999)
            c32 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox2.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox43.Text = Mid(str, 4, 9999)
            c43 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox23.Text = Mid(str, 4, 9999)
            c23 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox33.Text = Mid(str, 4, 9999)
            c33 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox3.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox44.Text = Mid(str, 4, 9999)
            c44 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox24.Text = Mid(str, 4, 9999)
            c24 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox34.Text = Mid(str, 4, 9999)
            c34 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox4.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox45.Text = Mid(str, 4, 9999)
            c45 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox25.Text = Mid(str, 4, 9999)
            c25 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox35.Text = Mid(str, 4, 9999)
            c35 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox5.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox46.Text = Mid(str, 4, 9999)
            c46 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox26.Text = Mid(str, 4, 9999)
            c26 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox36.Text = Mid(str, 4, 9999)
            c36 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox6.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox47.Text = Mid(str, 4, 9999)
            c47 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox27.Text = Mid(str, 4, 9999)
            c27 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox37.Text = Mid(str, 4, 9999)
            c37 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox7.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox48.Text = Mid(str, 4, 9999)
            c48 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox28.Text = Mid(str, 4, 9999)
            c28 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox38.Text = Mid(str, 4, 9999)
            c38 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox8.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox49.Text = Mid(str, 4, 9999)
            c49 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox29.Text = Mid(str, 4, 9999)
            c29 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox39.Text = Mid(str, 4, 9999)
            c39 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox9.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox50.Text = Mid(str, 4, 9999)
            C50 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox30.Text = Mid(str, 4, 9999)
            c30 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox40.Text = Mid(str, 4, 9999)
            c40 = Mid(str, 4, 9999)
            str = LineInput(n4)
            TextBox10.Text = Val(Mid(str, 4, 9999))

            str = LineInput(n4)
            ComboBox1.Text = Mid(str, 4, 9999)
            c1 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox11.Text = Mid(str, 4, 9999)
            c11 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox2.Text = Mid(str, 4, 9999)
            c2 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox12.Text = Mid(str, 4, 9999)
            c12 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox3.Text = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox13.Text = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox4.Text = Mid(str, 4, 9999)
            c4 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox14.Text = Mid(str, 4, 9999)
            c14 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox5.Text = Mid(str, 4, 9999)
            c5 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox15.Text = Mid(str, 4, 9999)
            c15 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox6.Text = Mid(str, 4, 9999)
            c6 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox16.Text = Mid(str, 4, 9999)
            c16 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox7.Text = Mid(str, 4, 9999)
            c7 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox17.Text = Mid(str, 4, 9999)
            c17 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox8.Text = Mid(str, 4, 9999)
            c8 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox18.Text = Mid(str, 4, 9999)
            c18 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox9.Text = Mid(str, 4, 9999)
            c9 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox19.Text = Mid(str, 4, 9999)
            c19 = Mid(str, 4, 9999)

            str = LineInput(n4)
            ComboBox10.Text = Mid(str, 4, 9999)
            c10 = Mid(str, 4, 9999)
            str = LineInput(n4)
            ComboBox20.Text = Mid(str, 4, 9999)
            c20 = Mid(str, 4, 9999)

            FileClose(n4)

        Catch
            MsgBox("定義ファイルエラー:エラーNO:" &
            Err.Number & vbCr & Err.Description & vbCr &
            "終了します。")
            End
        End Try



    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

        F2str = Replace(lblselect.Text, "select", "select top 50000 ") & " " & lblwhere.Text & " " & lblorder.Text
        Dim iform3 As New Form3
        iform3.ShowDialog()

    End Sub
End Class

Form3

Imports System.Data.OleDb

Public Class Form3

    Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Cursor = Cursors.WaitCursor

        Dim co As New OleDb.OleDbConnection
        Dim oleda As OleDb.OleDbDataAdapter
        Dim dtset As DataSet = New DataSet("tbl")
        Dim dttable As DataTable
        Dim dtcolumn As DataColumn
        Dim dtrow As DataRow
        Dim st As String

        Dim i As Integer
        Dim j As Integer

        ListView1.View = View.Details
        ListView1.Clear()

        '***************************************
        '* 初期処理
        '***************************************
        Try
            co.ConnectionString = CoString

            co.Open()

            '***************************************
            '* データの取得
            '***************************************

            st = F2Str

            oleda = New OleDb.OleDbDataAdapter(st, co)

            oleda.Fill(dtset, tblname)

            dttable = dtset.Tables(tblname)
            ListView1.Columns.Add("行数", 50, HorizontalAlignment.Left)
            For i = 0 To dttable.Columns.Count - 1
                dtcolumn = dttable.Columns(i)
                ListView1.Columns.Add(dtcolumn.ColumnName.ToString, 100, HorizontalAlignment.Left)
            Next

            ListView1.Visible() = False

            For i = 0 To dttable.Rows.Count - 1
                Dim LV As New ListViewItem((i + 1).ToString)
                For j = 0 To dttable.Columns.Count - 1
                    LV.SubItems.Add(dttable.Rows(i)(j).ToString)
                Next
                ListView1.Items.Add(LV)
            Next

            '***************************************
            '* 終了処理
            '***************************************

            co.Close()

        Catch ex As OleDbException
            MsgBox(st & "データベース接続エラーです。" & vbCr &
                   ex.Message & vbCr &
                   "検索終了します。FORM LOAD")
            'Exit Sub
        End Try

        ListView1.Visible() = True

        Me.Cursor = Cursors.Arrow

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Close()

    End Sub

End Class

Form4

Public Class Form4
    Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim stCurrentDir As String = System.IO.Directory.GetCurrentDirectory()
        Dim n2 As Integer = FreeFile()
        Dim st As String

        Try

            n = FreeFile()
            FileOpen(n, stCurrentDir & "\PARA.ini", OpenMode.Input)
            TextBox1.Text = LineInput(n)
            TextBox2.Text = LineInput(n)
            TextBox3.Text = LineInput(n)
            TextBox4.Text = LineInput(n)
            TextBox5.Text = LineInput(n)
            TextBox6.Text = LineInput(n)
            FileClose(n)

        Catch

            FileOpen(n2, stCurrentDir & "\PARA.ini", OpenMode.Output)
            st = ""
            PrintLine(n2, st)

            PrintLine(n2, st)

            PrintLine(n2, st)

            PrintLine(n2, st)

            PrintLine(n2, st)

            PrintLine(n2, st)
            FileClose(n2)

        End Try

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim stCurrentDir As String = System.IO.Directory.GetCurrentDirectory()
        Dim n2 As Integer = FreeFile()
        Dim st As String

        FileOpen(n2, stCurrentDir & "\PARA.ini", OpenMode.Output)
        st = TextBox1.Text
        PrintLine(n2, st)
        st = TextBox2.Text
        PrintLine(n2, st)
        st = TextBox3.Text
        PrintLine(n2, st)
        st = TextBox4.Text
        PrintLine(n2, st)
        st = TextBox5.Text
        PrintLine(n2, st)
        st = TextBox6.Text
        PrintLine(n2, st)
        FileClose(n2)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.Close()

    End Sub
    Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

        If e.KeyCode = Keys.End Then
            Me.Close()
        End If

    End Sub

End Class

-windows

PAGE TOP