I'm trying to update a SQL Server table using SqlCommand, however, the table never gets updated when I run the code
My ASPX:
<label id="lblEmail">Email:</label>
<asp:TextBox id="txtEmail" runat="server"/>
<label id="lblcode">Code:</label>
<asp:TextBox id="txtCode" runat="server"/>
<asp:ImageButton ID="btnSubmit" runat="server" ImageUrl="Images/Submit.gif" OnClick="btnSubmit_Click" Width="80px"/>
<asp:ImageButton ID="btnReset" runat="server" ImageUrl="Images/Reset.gif" OnClick="btnReset_Click" Width="80px"/>
This is my aspx.cs:
protected void btnSubmit_Click(object sender, EventArgs e)
{
string Email = txtEmail.Text.ToString();
string AttendingCode = txtRegCode.Text.ToString();
SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=bkdb;User ID=sa;Password=sa");
SqlCommand cmd = new SqlCommand("UPDATE Registration SET [Attending] = 1 WHERE [Email] = '@Email' and [AttendingCode] LIKE '%@AttendingCode%'", con);
cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = Email;
cmd.Parameters.Add("@AttendingCode", SqlDbType.VarChar).Value = AttendingCode;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}