I have some problem in sqlcommand where condition to implement the c# coding
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ccc"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select [Town Name] from town where '" + DropDownList1.SelectedItem.Text + "' <= '" + TextBox1.Text + "'", con);
//ListBox1.Text = cmd.ExecuteScalar().ToString();
TextBox4.Text = cmd.ExecuteScalar().ToString();
con.Close();
In This coding after Where condition not use to textbox,label,dropdownlist,etc
how can I use textbox,label,dropdownlist,etc
send me answer quickly to [email protected]
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


sarfaraj md154 reputationPosted Nov 20, 2012, 9:37 PM EST
Pradip PandeyRank #452 · 5.6K reputationPosted Nov 21, 2012, 12:17 AM EST
SqlConnection(....
where
if columnname1 is integer type of filed then use DropDownList1.SelectedValue.
if columnname1 is varchar type of filed then use DropDownList1.SelectedItem.Text.
Hope it will help.