尝试使用条件进行搜索

时间:2018-07-19 15:48:41

标签: visual-studio-2010

我正在尝试根据文本框条目搜索名字和姓氏,并在日期之间进行检查

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            Dim table As New DataTable()
            Dim command As New MySqlCommand("SELECT  fname,lname,date_of_test FROM testing_data inner join demography where Date_of_test between @d1 and @d2 and fname  like '%{0}%' and  lname like '%{0}%' ", mysqlconn)


            ' command.Parameters.Add("@icooc", MySqlDbType.VarChar).Value = ComboBox_icooc.SelectedItem
            command.Parameters.Add("@d1", MySqlDbType.Date).Value = DateTimePicker1.Value
            command.Parameters.Add("@d2", MySqlDbType.Date).Value = DateTimePicker2.Value
            command.Parameters.Add("@n1", MySqlDbType.VarChar).Value = Format("@n1 like '%{0}%' ", TextBox1.Text)
            command.Parameters.Add("@n2", MySqlDbType.VarChar).Value = Format("@n2 like '%{0}%' ", TextBox2.Text)

            Dim adapter As New MySqlDataAdapter(command)

            adapter.Fill(table)

            DataGri`enter code here`dView2.DataSource = table
        End Sub

0 个答案:

没有答案