This is my code
string srch1;
string srch2;
if (cb1.SelectedItem.ToString() == "Book Title")
{
srch1 = "Book_Title";
}
else if (cb1.SelectedItem.ToString() == "Call Number")
{
srch1 = "Call_Number";
}
else
{
srch1 = "Accession_Number";
}
if (cb2.SelectedItem.ToString() == "Ascending Order")
{
srch2 = "ASC";
}
else
{
srch2 = "DESC";
}
cmd = new SqlCommand("select * from Book where '"+ srch1 +"' = @input ORDER BY "+ srch1 +" " + srch2 + "", con);
cmd.Parameters.Add("@input", SqlDbType.NVarChar).Value = input.Text;
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
When I tried to search through the records. It doesn't show any result. Why is that? I really doubt that my sql query has something to do with it as it has many conditions. Could someone please take a look?