So I want to be able to update the details of the user that is logged in. So I have multiple attributes that I would like to update however I want the user not have to enter their ID each time they would like to change something. This is my code under the save button however nothing happens except redirect to the other page. Any help would be kindly appreciated
protected void btnTenantSave_Click(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//Creating a connection to my database using the connection string
string cs = System.Configuration.ConfigurationManager.ConnectionStrings["rent-dbConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
//preparing a query which will update the data in the database with the data entered into the textboxes
SqlCommand cmd = new SqlCommand("UPDATE Tenants SET Tenant_FullName='" + this.txtTenantFullName.Text + "',Tenant_Email='" + this.txtTenantEmail.Text + "',Tenant_TelNum='" + this.txtTenantTelNum.Text + "',Tenant_EmName= '" + this.txtTenantEmName.Text + "',Tenant_EmNum= '" + this.txtTenantEmNum.Text + "',Tenant_WorkStatus= '" + this.txtWorkstatus.Text + "'Where Tenant_Email='" + Session["TenantLogin"] + "';", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
Response.Redirect("TenantIndex.aspx");
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Srikant MaruwadaPosted Jan 31, 2018, 3:51 AM
Chetan RanpariyaPosted Jan 31, 2018, 3:41 AM