Posted on: 7/15/2014 9:07:24 AM | Views : 399

Hi how to insert no duplicate values in asp.net for a column with out unique key constraint. Not getting for this code

SqlConnection conn = new SqlConnection(cs); conn.Open(); String str = "select count(*)from Sva_Products where Product_name ='" +txt_pname.Text +"'"; SqlCommand cmd1 = new SqlCommand(str, conn); int count = Convert.ToInt32(cmd1.ExecuteScalar()); conn.Close(); if (count > 0) { Page.Controls.Add(new LiteralControl("<script>alert('Product Name already exists!.');</script>")); }

Go to the complete details ...