Imports System.Data
Imports System.Data.OleDb
Public Class Form2
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If example.Text = "ID Code" Then
sql = "select * from factory1 where ID_Code Like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Plt Bld Id" Then
sql = "select * from factory1 where Plt_Bld_Id Like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Tsic Id" Then
sql = "Select * from factory1 where Tsic_Id like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Id No" Then
sql = "Select * from factory1 where Id_No like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Number Factory" Then
sql = "Select * from factory1 where Number_Factory like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Type code factory" Then
sql = "Select * from factory1 where Type_code_factory like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Industry" Then
sql = "Select * from factory1 where Industry like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Corporate Name" Then
sql = "Select * from factory1 where Corporate_Name like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Factory_Building" Then
sql = "Select * from factory1 where Factory_Building like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Trader" Then
sql = "Select * from factory1 where Trader like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Name Contract" Then
sql = "Select * from factory1 where Name_Contract like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Date control" Then
sql = "Select * from factory1 where Date_control like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Acc responsible" Then
sql = "Select * from factory1 where Acc_responsible like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Address" Then
sql = "Select * from factory1 where Address like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Address Estate" Then
sql = "Select * from factory1 where Address_Estate like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Group" Then
sql = "Select * from factory1 where Group like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Road" Then
sql = "Select * from factory1 where Road like '" & TextBox1.Text & "%'"
ElseIf example.Text = "District" Then
sql = "Select * from factory1 where District like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Zone" Then
sql = "Select * from factory1 where Zone like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Province" Then
sql = "Select * from factory1 where Province like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Post Code" Then
sql = "Select * from factory1 where Post_Code like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Number" Then
sql = "Select * from factory1 where Number like '" & TextBox1.Text & "%'"
ElseIf example.Text = "NumberFax" Then
sql = "Select * from factory1 where NumberFax like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Expr1014" Then
sql = "Select * from factory1 where Expr1014 like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Transformer size (kVA) SUM" Then
sql = "Select * from factory1 where Transformer_size like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Size kW approval SUM" Then
sql = "Select * from factory1 where Size_kW_approval like '" & TextBox1.Text & "%'"
End If
dt.Clear()
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sql = "Select * from factory1"
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
Dim _DR As DataRow
Dim _DT As New DataTable
_DT.Columns.Add("Data")
_DT.Columns.Add("SQLString")
_DR = _DT.NewRow
_DR("Data") = "น้อยกว่า 1175"
_DR("SQLString") = "Transformer_size < 1175"
_DR("Data") = "1175 ถึง 3529"
_DR("SQLString") = "Transformer_size >= 1175 And Transformer_size <= 3529"
_DT.Rows.Add(_DR)
_DR = _DT.NewRow
_DR("Data") = "มากกว่า 3529"
_DR("SQLString") = "Transformer_size > 3529"
_DT.Rows.Add(_DR)
c2.DataSource = _DT
c2.DisplayMember = "Data"
c2.ValueMember = "SQLString"
End Sub
Private Sub example_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles example.SelectedIndexChanged
Try
Me.Text = c2.SelectedValue
Catch ex As Exception
c2.Text = Nothing
End Try
End Sub
Private Sub c2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c2.SelectedIndexChanged
End Sub
End Class
On Error Resume Next
sql = "Select * from factory1 where " & c2.SelectedValue & "
dt.Clear()
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If example.Text = "ID Code" Then
sql = "select * from factory1 where ID_Code Like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Plt Bld Id" Then
sql = "select * from factory1 where Plt_Bld_Id Like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Tsic Id" Then
sql = "Select * from factory1 where Tsic_Id like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Id No" Then
sql = "Select * from factory1 where Id_No like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Number Factory" Then
sql = "Select * from factory1 where Number_Factory like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Type code factory" Then
sql = "Select * from factory1 where Type_code_factory like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Industry" Then
sql = "Select * from factory1 where Industry like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Corporate Name" Then
sql = "Select * from factory1 where Corporate_Name like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Factory_Building" Then
sql = "Select * from factory1 where Factory_Building like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Trader" Then
sql = "Select * from factory1 where Trader like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Name Contract" Then
sql = "Select * from factory1 where Name_Contract like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Date control" Then
sql = "Select * from factory1 where Date_control like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Acc responsible" Then
sql = "Select * from factory1 where Acc_responsible like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Address" Then
sql = "Select * from factory1 where Address like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Address Estate" Then
sql = "Select * from factory1 where Address_Estate like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Group" Then
sql = "Select * from factory1 where Group like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Road" Then
sql = "Select * from factory1 where Road like '" & TextBox1.Text & "%'"
ElseIf example.Text = "District" Then
sql = "Select * from factory1 where District like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Zone" Then
sql = "Select * from factory1 where Zone like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Province" Then
sql = "Select * from factory1 where Province like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Post Code" Then
sql = "Select * from factory1 where Post_Code like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Number" Then
sql = "Select * from factory1 where Number like '" & TextBox1.Text & "%'"
ElseIf example.Text = "NumberFax" Then
sql = "Select * from factory1 where NumberFax like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Expr1014" Then
sql = "Select * from factory1 where Expr1014 like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Transformer size (kVA) SUM" Then
sql = "Select * from factory1 where Transformer_size like '" & TextBox1.Text & "%'"
ElseIf example.Text = "Size kW approval SUM" Then
sql = "Select * from factory1 where Size_kW_approval like '" & TextBox1.Text & "%'"
End If
dt.Clear()
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sql = "Select * from factory1"
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
Dim _DR As DataRow
Dim _DT As New DataTable
_DT.Columns.Add("Data")
_DT.Columns.Add("SQLString")
_DR = _DT.NewRow
_DR("Data") = "น้อยกว่า 1175"
_DR("SQLString") = "Transformer_size between 0 and 1175 "
_DR("Data") = "1175 ถึง 3529"
_DR("SQLString") = "Transformer_size between 1176 and 3529"
_DT.Rows.Add(_DR)
_DR = _DT.NewRow
_DR("Data") = "มากกว่า 3529"
_DR("SQLString") = "Transformer_size between 3530 and 100000000"
_DT.Rows.Add(_DR)
c2.DataSource = _DT
c2.DisplayMember = "Data"
c2.ValueMember = "SQLString"
End Sub
Private Sub example_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles example.SelectedIndexChanged
Try
Me.Text = c2.SelectedValue
Catch ex As Exception
c2.Text = Nothing
End Try
End Sub
Private Sub c2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c2.SelectedIndexChanged
On Error Resume Next
sql = "Select * from factory1 where " & c2.SelectedValue & ""
dt.Clear()
da = New OleDbDataAdapter(sql, Conn)
da.Fill(dt)
dtg.DataSource = dt
End Sub
End Class