-2
3つの異なるcomboBoxを使用しているデータベースからデータを検索したいと思います。C#を使用した複数のCombobox検索
検索ボタンをクリックしてクリックした後、データをすべての選択コンボボックスに表示します。
データは、私が選択した3つのコンボボックスから正確に表示されるはずです。どうすればいい?助けてくれてありがとう。
他の場合は使用しますが、上記のように変更したいと考えています。
private void btnsubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\acap\Documents\Data.mdf;Integrated Security=True;Connect Timeout=30");
DataTable ds = new DataTable();
if (comboBox1.Text.Length > 0)
{
SqlDataAdapter sda = new SqlDataAdapter("SELECT No_ic as [I/C No.], Name as [Name], Program as [Program], No_Matric as [Matric No.], No_HP as [Handphone No.], Address as [Address], State as [State], Kohort as [Kohort] FROM Student where Program LIKE '" + comboBox1.Text + "%' ", con);
sda.Fill(ds);
}
else if (comboBox2.Text.Length > 0)
{
SqlDataAdapter sda = new SqlDataAdapter("SELECT No_ic as [I/C No.], Name as [Name], Program as [Program], No_Matric as [Matric No.], No_HP as [Handphone No.], Address as [Address], State as [State], Kohort as [Kohort] FROM Student where State LIKE '" + comboBox2.Text + "%' ", con);
sda.Fill(ds);
}
else if (comboBox3.Text.Length > 0)
{
SqlDataAdapter sda = new SqlDataAdapter("SELECT No_ic as [I/C No.], Name as [Name], Program as [Program], No_Matric as [Matric No.], No_HP as [Handphone No.], Address as [Address], State as [State], Kohort as [Kohort] FROM Student where Kohort LIKE '" + comboBox3.Text + "%' ", con);
sda.Fill(ds);
}
クエリは何ですか? – Krishna
私は上記の私のコードと質問を編集するだけです。 @Krishna –