title: IF ELSE condition asp net with SQL Server
body: <pre><code>string conn = "";
  
  conn = ConfigurationManager.ConnectionStrings["Conn"].ToString();
  SqlConnection objsqlconn = new SqlConnection(conn);
  
  objsqlconn.Open();
  
  SqlCommand objcmd = new SqlCommand("IF (select 1 from PRODUCT where PRODUCT_NAME=" + Master_product_txt.Text + ")=1
      PRINT 'ALREADY AVAILABLE'
  ELSE
      Insert into PRODUCT(PRODUCT_NAME) Values('" + Master_product_txt.Text + "')
  GO", objsqlconn);
  
  objcmd.ExecuteNonQuery();
  
  MessageBox.Show("Details Successfully Added!!!");
  </code></pre>
  
  <p>I'm trying check the data base values before insert the value, I've wrote query for it, it's working in sql server environment, I could not able to implement same thing in Visual Studio</p>