i am using a combobox including Name Company and Country so the user could choose from them to specify what form does he want to search in a textbox and i need to view my search results in a different form (results.cs) and my search engine is on (main.cs) how could i do it ?
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
if (comboBox1.Text == "Name")
{
String var;
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Seif-\Documents\Visual Studio 2013\Projects\BusinessCard\BusinessCard\BusinessCards.mdf;Integrated Security=True");
SqlCommand sc = new SqlCommand("SELECT Name, Post, Company, Country, Email, Mobile, Tel1, Tel2, Fax, Address FROM BC where Name LIKE '" + textBox1.Text + "'", conn);
SqlDataAdapter sda = new SqlDataAdapter(sc);
DataTable dt = new DataTable();
sda.Fill(dt);
var = (string)sc.ExecuteScalar();
Search f2 = new Search();
f2.Show();
}
else if (comboBox1.Text == "Company")
{
String var;
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Seif-\Documents\Visual Studio 2013\Projects\BusinessCard\BusinessCard\BusinessCards.mdf;Integrated Security=True");
SqlCommand sc = new SqlCommand("SELECT Name, Post, Company, Country, Email, Mobile, Tel1, Tel2, Fax, Address FROM BC where Company LIKE '" + textBox1.Text + "'", conn);
SqlDataAdapter sda = new SqlDataAdapter(sc);
DataTable dt = new DataTable();
sda.Fill(dt);
var = (string)sc.ExecuteScalar();
Search f2 = new Search();
f2.Show();
}
else if (comboBox1.Text == "Country")
{
String var;
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Seif-\Documents\Visual Studio 2013\Projects\BusinessCard\BusinessCard\BusinessCards.mdf;Integrated Security=True");
SqlCommand sc = new SqlCommand("SELECT Name, Post, Company, Country, Email, Mobile, Tel1, Tel2, Fax, Address FROM BC where Country LIKE '" + textBox1.Text + "'", conn);
SqlDataAdapter sda = new SqlDataAdapter(sc);
DataTable dt = new DataTable();
sda.Fill(dt);
var = (string)sc.ExecuteScalar();
Search f2 = new Search();
f2.Show();
}
}