Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void Button1_Click(object sender, EventArgs e)
   {   count++;
       int noofcount = count;
       Label6.Text = noofcount.ToString();
       if (noofcount > 5)
       {    string ch = "Attacker";

           
                     con = new SqlConnection("Data Source=Database; Initial Catalog=firecol; User Id=sa; Pwd=password");
           con.Open();

           cmd = new SqlCommand("update normaluser set type='" + ch + "' where username='" + Label5.Text + "'", con);
           cmd.ExecuteNonQuery();
           con.Close();
           count=0;
       }
       else
 {String bl = "", la = "";
           con = new SqlConnection("Data Source=FABSYS39\\SQLEXPRESS; Initial Catalog=firecol; User Id=sa; Pwd=saadmin");

           con.Open();
 cmd = new SqlCommand("Insert into questions Values('" + Label5.Text + "','" + ddldetails.SelectedItem.Text + "','" + DropDownList2.SelectedItem.Text + "','" + TextBox1.Text + "','" + la + "','" + bl + "')", con);
           cmd.ExecuteNonQuery();
           con.Close();
           Label4.Visible = true;
       }



i wanna clear this button clcik count while i leaving in this page....how can i clear that??? pls help me???
Posted
Updated 18-Nov-12 23:10pm
v2

1 solution

You can keep a flag that indicates you to reset. Then In the page load event check IsPostBack, if it is not true, not if your flag suggests you to reset count, reset it.

Wait a minute, Why are you giving your SQL server name, id, password in open?

Are you not scared !!!

Milind
 
Share this answer
 
Comments
Deenuji 19-Nov-12 5:29am    
tat password and id s fake ly sir....
Deenuji 19-Nov-12 5:29am    
now it's working correctly.... thank u sir....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900