Hope it helps!!c# Code:
//your SqlConnection here, name it conn //SqlCommand Sqlcommand cmd = new SqlCommand(); cmd.CommandText = "Select Count(studyIdNumber) from table_name WHERE studyIdNumber='FF12033'"; cmd.Connection = conn; conn.Open(); int num_of_instance = cmd.ExecuteScalar(); conn.Close(); if (num_of_instance == 1) { //Item already inserted } else { //Insert new Item }




Reply With Quote