Dim sqlland As String = ""
sqlland = "SELECT * FROM houseView_1"
If rediobutton1.Checked = True Then
sqlland &= " WHERE (HOUSEID='" & txtsearch.Text & "')"
ElseIf rediobutton2.Checked = True Then
sqlland &= " WHERE (FIRSTNAME = '" & txtsearch.Text & "')"
ElseIf rediobutton3.Checked = True Then
sqlland &= " WHERE (HOUSENO='" & txtsearch.Text & "')"
End If
sqlland &= " ORDER BY HOUSEID"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnstring
.Open()
End With
da = New SqlDataAdapter(sqlland, Conn)
da.Fill(ds, "houseView_1")
myGridView.DataSource = ds.Tables("houseView_1")
txtsearch.Clear()
Dim cs As New DataGridViewCellStyle
cs.Font = New Font("ms sans serif", 10, FontStyle.Regular)
cs.Alignment = DataGridViewContentAlignment.MiddleCenter
cs.ForeColor = Color.Blue
With myGridView
.ColumnHeadersDefaultCellStyle = cs
.Columns(0).HeaderText = "HOUSEID"
.Columns(1).HeaderText = "คำนำหน้าชื่อ"
.Columns(2).HeaderText = "ชื่อ"
.Columns(0).Width = 180
.Columns(1).Width = 140
.Columns(2).Width = 100
.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(2).SortMode = DataGridViewColumnSortMode.NotSortable
End With
End Sub