Hi Adil,
Please update your code as below.
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source = .\SQLEXPRESS;AttachDbFilename=E:\project\Projects\labelnameinsecondformtry\labelnameinsecondformtry\Database1.mdf;Integrated Security=True;User Instance=True";
try
{
conn.Open();
string qry2 = "UPDATE Table1 SET Password =@Password WHERE UserName=@username";
SqlCommand com = new SqlCommand(qry2, conn);
com.Parameters.AddWithValue("@username", this.textBox1.Text);
com.Parameters.AddWithValue("@Password", this.textBox2.Text);
int result = com.ExecuteNonQuery();
if (result > 0)
{
MessageBox.Show("updated sucesfull");
}
else
MessageBox.Show("updated failed");
}
catch (Exception)
{
MessageBox.Show("Error with the databse connection");
}
Hope this will help you.