Sir I am having a page web4.aspx
it has a text field
the value of this text field i am passing to default2.aspx using QUERY STRING
In default2.aspx i am trying to update a row
after the execution error is coming as follows:
ExecuteNonQuery: Connection property has not been initialized.
Exception Details: System.InvalidOperationException: ExecuteNonQuery: Connection property has not been initialized.
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
Label1.Text = Request.QueryString["s"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
else if(RadioButton4.Checked )
{
string z = "Voted";
//Label1.Text = "ABCDEF1234";
SqlCommand cmd3 = new SqlCommand("UPDATE [users] SET [Address] = @Address WHERE [ElectionId] = @ElectionId, con");
cmd3.Parameters.AddWithValue("@Address", z);
cmd3.Parameters.AddWithValue("@ElectionId", Label1.Text);
cmd3.ExecuteNonQuery();
con.Close();
}
else
{
Response.Write("please select your choice");
}
}
}