7
Reply

get Data from database

anuj

anuj

Jan 14 2016 5:23 AM
376
how to get data  from database ....
 
               

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
           


 try
            {
                con.Open();


                SqlCommand cmd = new SqlCommand("select id from customer where Name ='" +comboBox1.SelectedValue + "'", con);


                int anuj1 = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();

                if (anuj1 > 0)
                {



                    txtid.Text = Convert.ToString(anuj1);
                }








            }
            catch
            {



            }

Answers (7)