hello i'am a student and i have a project website that have a registration form and sql database i want to limit the registration maximum is 50 then when the limit is reach user cannot allowed to register something like that.
protected void Button1_Click(object sender, EventArgs e)
{
if (temp == 0)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["registrationConnectionString"].ConnectionString);
conn.Open();
string insertquerry = "insert into userdata(VerificationNumber,FirstName,LastName,Gender,Birthday,CivilStatus,EmailID,MobileNumber,Address,DateRegistered,ExamSchedule) values (@VERIFY ,@FN ,@LN ,@GENDER ,@MONTH ,@CS ,@EMAIL ,@CP ,@ADRESS ,@DATE ,@SCHED)";
SqlCommand com = new SqlCommand(insertquerry, conn);
com.Parameters.AddWithValue("@VERIFY", TextBoxVERIFY.Text);
com.Parameters.AddWithValue("@FN", TextBoxFN.Text);
com.Parameters.AddWithValue("@LN", TextBoxLN.Text);
com.Parameters.AddWithValue("@GENDER", DropDownListGENDER.SelectedItem.ToString());
com.Parameters.AddWithValue("@MONTH", TextBoxBD.Text);
com.Parameters.AddWithValue("@CS", DropDownListCS.SelectedItem.ToString());
com.Parameters.AddWithValue("@EMAIL", TextBoxEMAIL.Text);
com.Parameters.AddWithValue("@CP", TextBoxCP.Text);
com.Parameters.AddWithValue("@ADRESS", TextBoxADRESS.Text);
com.Parameters.AddWithValue("@DATE", LabelTIME.Text);
LabelTIME.Text = DateTime.Now.ToString();
com.Parameters.AddWithValue("@SCHED", DropDownListSCHED.SelectedItem.ToString());
com.ExecuteNonQuery();
StreamWriter thepath = new StreamWriter("C:\\inetpub\\ftproot\\reg.txt", true);
using (StreamWriter writer = (thepath))
{
writer.WriteLine("[" + TextBoxFN.Text + "]" + "[" + TextBoxLN.Text + "]" + "[" + TextBoxVERIFY.Text + "]" + "[" + DropDownListGENDER.SelectedItem.ToString() + "]" + "[" + TextBoxBD.Text + "]" + "[" + DropDownListCS.SelectedItem.ToString() + "]" + "[" + TextBoxEMAIL.Text + "]" + "[" + TextBoxCP.Text + "]" + "[" + TextBoxADRESS.Text + "]" + "[" + LabelTIME.Text + "]" + "[" + DropDownListSCHED.SelectedItem.ToString() + "]");
}
{
Session["VerificationNumber"] = TextBoxVERIFY.Text;
}
Response.Redirect("registersuccess.aspx");
conn.Close();
}
catch (Exception ex)
{
Response.Write("Error:" + ex.ToString());
}
}
}