Durga Velusamy

Durga Velusamy

  • NA
  • 318
  • 108.8k

how create automatic ID with database connection

Mar 28 2015 3:02 AM

        private void button2_Click_1(object sender, EventArgs e)

        {

         SqlConnection con = new SqlConnection(@"server=CSE-PC; integrated security=true; Database=Bas");

                con.Open();

 

the below code need to check with database .i.e the colum :ID if it is count 0 means excute else contion otherwise starts with if condition. How to check this ?

 

            if (i > 0)

            {

            

                int j = i + 1;

                strc00 = "C00" + j.ToString();

 

            }

            else

            {

                strc00 = "C001";

            }

            comboBox1.Items.Add(strc00);

            i++;

            MessageBox.Show("id created");

          

}


Answers (2)