Imports System.Data.SqlClient
Public Class frmRuZhuChaXun
Dim conn As SqlConnection = GetConnection()
Dim strSql As String = "Select * From 住宿登记"
Dim myda As New SqlDataAdapter(strSql, conn)
Dim mydt As DataTable
Private Sub FillDataAndView()
mydt = New DataTable
myda.Fill(mydt)
End Sub
Private Sub frmRuZhuChaXun_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
Me.Close()
frmMain.Show()
End Sub
Private Sub frmRuZhuChaXun_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FillDataAndView()
cmbMode.SelectedIndex = 0
DataGridView1.DataSource = mydt
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
DataGridView1.DataSource = Nothing
strSql = "Select * From 住宿登记 Where " & cmbMode.Text & " like '%{0}%'"
strSql = String.Format(strSql, txtCondition.Text)
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, conn)
Dim dt As New DataTable
Try
da.Fill(dt)
Catch ex As Exception
MsgBox("不存在")
End Try
DataGridView1.DataSource = dt
End Sub
Private Sub btnRef_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRef.Click
frmRuZhuChaXun_Load(sender, e)
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
frmMain.Show()
End Sub
End Class