samedi 25 avril 2015

Updating database gives "The multi-part identifier could not be bound." Error

I'm trying to update the BookingID in the CounselorDB table. It's previously null. cID is a String that contains the predefined CounselorID.

The error I'm getting is the multi-part identifier "x" could not be bound; x being the cID.

Thank you.

 using (SqlConnection connection = new SqlConnection(connectionString))
    {
        String sql = string.Format("UPDATE CounselorDB SET BookingID = @BookingID WHERE CounselorID = " + cID);
        SqlCommand cmd = new SqlCommand(sql, connection);
        cmd.CommandType = CommandType.Text;
        cmd.Connection = connection;
        cmd.Parameters.AddWithValue("@BookingID", getBookingID());
        connection.Open();
        cmd.ExecuteNonQuery();
    }

Aucun commentaire:

Enregistrer un commentaire