使用asp.net c#注册限制 [英] registration limit using asp.net c#
本文介绍了使用asp.net c#注册限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我是一名学生,我有一个项目网站,有一个注册表格和sql数据库,我想限制注册最大值是50然后当限制达到用户不能允许注册这样的东西。
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());
}
}
}
推荐答案
你应该写c#代码在.aspx.cs代码背后
//首先采取
int i = 0;
You should write c# code on .aspx.cs code behind
//First take
int i= 0;
这篇关于使用asp.net c#注册限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文