What's wrong?
Compiletor don't show anything, but whet I start program show this error:
"Error updating the employee details!"
Compiletor don't show anything, but whet I start program show this error:
"Error updating the employee details!"
Code:
protected void Button1_Click(object sender, EventArgs e) { //416 puslapis // Declare objects SqlConnection conn; SqlCommand comm; // Read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings[ "Dorknozzle"].ConnectionString; // Initialize connection conn = new SqlConnection(connectionString); // Create command comm = new SqlCommand( "UPDATE Employees SET Name=@Name, City=@City " + "MobilePhone=@MobilePhone " + "WHERE EmployeeID=@EmployeeID", conn); // Add command parameters comm.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@Name"].Value = TextBox1.Text; comm.Parameters.Add("@City", System.Data.SqlDbType.NVarChar, 50); comm.Parameters["@City"].Value = TextBox2.Text; comm.Parameters.Add("@EmployeeID", System.Data.SqlDbType.Int); comm.Parameters["@EmployeeID"].Value = TextBox3.Text; // Enclose database code in Try-Catch-Finally try { // Open the connection conn.Open(); // Execute the command comm.ExecuteNonQuery(); } catch { // Display error message Label1.Text = "Error updating the employee details!<br />"; } finally { // Close the connection conn.Close(); } // Refresh the employees list //LoadEmployeesList(); }
Comment