Can anyone help me with this issue. i am trying to insert data in a local DB from my .NET app but it throws me Object Reference Exception. You can se my code below:
protected void Save_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Rights"].ConnectionString);
con.Open();
string insert = "insert into userinfo(Name,Mbiemri) values (@Name,@Mbiemri)";
SqlCommand cnd = new SqlCommand(insert, con);
cnd.Parameters.AddWithValue("@Name", TextBox1.Text);
cnd.Parameters.AddWithValue("@Mbiemri", TextBox2.Text);
cnd.ExecuteNonQuery();
Response.Redirect("Home.aspx");
con.Close();
}
catch (Exception ex)
{
Response.Write(ex);
}
}
and i think that this is the line that throws the exception SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Rights"].ConnectionString);
please give me some solution cuz there are days i am working with this.