samedi 25 avril 2015

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


Im trying to update the BookingID in the CounselorDB table. Its previously null. cID is a String that contains the predefined CounselorID.

The error im 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