Hi experts,
(I hope I didn't post my question in the wrong category of the forum)
I am using in C#, Asp.Net, SQL Server for my project.
I have a situation whereby I need to update a primary key.
In my table, I have these columns:
proj_id, emp_name, emp_email
I have the following method
public static void updatePID(String newpid,String oldpid)
{
SqlConnection conn = new SqlConnection(connString);
SqlCommand comm = new SqlCommand("Update table_name set proj_id = newpid where proj_id = oldpid");
conn.Open();
comm.Connection = conn;
comm.Parameters.AddWithValue("@projectid", newpid);
comm.Parameters.AddWithValue("@projectid", oldpid);
comm.ExecuteNonQuery();
conn.Close();
}
I have a problem with the following two statements.
comm.Parameters.AddWithValue("@projectid", newpid);
comm.Parameters.AddWithValue("@projectid", oldpid);
My connection with the database and the variables "newpid" and "oldpid" values are correct.
May I know if there is any other methods to update a primary using the old primary key? Thank You in Advance.