Есть две таблицы, которые объединяются с помощью запроса
SELECT disciplina.nazvanie, disciplina.kolvo, disciplina.ekzzach, disciplina.uch, disciplina.spec,
dis.kursovoi From disciplina Inner Join dis On disciplina.nazvanie = dis.nazvanie
нужно сделать поиск по объединенной таблице
private void search_nazv()
{
try
{
if (textBox8.Text != string.Empty)
{
DataSet dataSet = new DataSet();
BindingSource binding = new BindingSource();
SqlDataAdapter poi = new SqlDataAdapter(@"SELECT disciplina.nazvanie, disciplina.kolvo, disciplina.ekzzach, disciplina.uch, disciplina.spec,
dis.kursovoi From disciplina Inner Join dis On disciplina.nazvanie = dis.nazvanie FROM dis O WHERE O.nazvanie LIKE N'%" + this.textBox8.Text + "%'", conpoezdb);
poi.Fill(dataSet, "dis");
binding = new BindingSource(dataSet, "dis");
dataGridView2.DataSource = binding;
}
}
catch (SqlException sqlExcept)
{ MessageBox.Show(sqlExcept.Message); }
}
private void search_fio()
{
try
{
if (textBox8.Text != string.Empty)
{
DataSet dataS = new DataSet();
BindingSource binding = new BindingSource();
SqlDataAdapter poi = new SqlDataAdapter(@"SELECT disciplina.nazvanie, disciplina.kolvo, disciplina.ekzzach, disciplina.uch, disciplina.spec,
dis.kursovoi From disciplina Inner Join dis On disciplina.nazvanie = dis.nazvanie FROM disciplina K WHERE K.fio LIKE N'%" + this.textBox8.Text + "%'", conpoezdb);
poi.Fill(dataS, "dis");
binding = new BindingSource(dataS, "dis");
dataGridView2.DataSource = binding;
}
}
catch (SqlException sqlExcept)
{ MessageBox.Show(sqlExcept.Message); }
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "nazvanie")
{
SqlConnection po = new SqlConnection("Data Source=JUSTYX;Initial Catalog=julia;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter(@"SELECT nazvanie, kolvo, fio, ekzzach, uch, spec, kursovoi FROM dis WHERE nazvanie like '%" + textBox8.Text + "%' ", po);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView2.DataSource = dt;
}
else if (comboBox1.Text == "fio")
{
SqlConnection po = new SqlConnection("Data Source=JUSTYX;Initial Catalog=julia;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT nazvanie, kolvo, fio, ekzzach, uch, spec, kursovoi FROM dis WHERE fio like '%" + textBox8.Text + "%'", po);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView2.DataSource = dt;
}
}