If user enter more than one value to same date then value not entered in table.
If date change then value entered in table in asp c#
namespace ProjectBarcode
{
public partial class WebForm4 : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand com;
string str = null;
// SqlConnection con = new SqlConnection(@"Data Source=10.1.246.4;Initial Catalog=DB_NTPC_MEJA_INTRANET; User ID=dba_ntpc_meja_intranet; Password=alpha$890; Connection Timeout=15;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=100;Pooling=true;");
// string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
namecheck();
if (!IsPostBack)
{
}
}
public void namecheck()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select count(*)from trans where Workman_ID='" + TextBox1.Text + "'";
com = new SqlCommand(str, con);
int count = Convert.ToInt32(com.ExecuteScalar());
con.Close();
if (count >1000000)
{
Label1.Text = "Sorry! Details has been already submited..";
}
else
{
Label1.Text = " Details has been submited !";
con.Open();
str = "insert into trans(Workman_ID) values('" + TextBox1.Text + "')";
com = new SqlCommand(str, con);
com.ExecuteNonQuery();
con.Close();
}
}
}
}