Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
try
            {
               
               
                con.Open();
                string search = "select Amount from Mess_Plans Where PlanName='" + comboBox1_SelectPlan.Text + "' ;";
                OleDbCommand cmd1 = new OleDbCommand(search, con);
                String i = cmd1.ExecuteReader();
                MessageBox.Show("slected" +i);
               
            }
            catch(Exception e2)
            {
                MessageBox.Show(e2.ToString());
            }
            finally
            {
                con.Close();
            }
Posted

1 solution

should be:
comboBox1_SelectPlan.SelectedValue

And you should use parameterized query to prevent sql injection, read these:
1. Hack Proof Your ASP.NET Applications From SQL Injection[^]
2. SQL Injection[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900