4,011
社区成员
发帖
与我相关
我的任务
分享
Dim sfstr As String = "SELECT * FROM modeldatatable WHERE"
If CheckBox1.Checked = True Then sfstr = sfstr & " people LIKE'" & Me.TextBox5.Text & "'"
If CheckBox2.Checked = True Then sfstr = sfstr & " f_path LIKE'" & Me.TextBox6.Text & "'"
If CheckBox3.Checked = True Then sfstr = sfstr & " f_class LIKE'" & Me.ComboBox1.Text & "'"
If CheckBox4.Checked = True Then sfstr = sfstr & " m_class LIKE'" & Me.ComboBox2.Text & "'"
If CheckBox5.Checked = True Then sfstr = sfstr & " m_location LIKE'" & Me.TextBox7.Text & "'"
Dim sfConnection As New SqlConnection("server=hustami;database=modeldata;integrated security=true")
Dim sfDataSet As New DataSet()
Dim sfDataAdapter As New SqlDataAdapter()
sfDataAdapter.SelectCommand = New SqlCommand()
sfDataAdapter.SelectCommand.Connection = sfConnection
sfDataAdapter.SelectCommand.CommandText = sfstr
sfDataAdapter.SelectCommand.CommandType = CommandType.Text
sfDataAdapter.SelectCommand.Connection.Open()
sfDataAdapter.SelectCommand.ExecuteNonQuery()
sfDataAdapter.Fill(sfDataSet, "modeldatatable")
sfDataAdapter.SelectCommand.Connection.Close()
Form1.DataGridView1.AutoGenerateColumns = True
Form1.DataGridView1.DataSource = sfDataSet
Form1.DataGridView1.DataMember = "modeldatatable"