Reputation: 1364
I got problem..
When user click CLEAR PHOTO, my picture box will change picture to picture "no_photo"..
That it`s my code
private void btnClearPhoto_Click(object sender, EventArgs e)
{
picEmp.Image = chuki2_spp.Properties.Resources.no_photo;
}
And when user modify current records. It will check photo is same or not from resources. If same, record will saved as DBNull.Value.
if (picEmp.Image == chuki2_spp.Properties.Resources.no_photo)
{
sqlComm.Parameters.AddWithValue("@empPicture", DBNull.Value);
}
else
{
sqlComm.Parameters.AddWithValue("@empPicture", data);
}
After user update record, it still keep old picture. Not change to null value in databases. How can I repair that code?
Upvotes: 1
Views: 499
Reputation: 6805
This is not working because picEmp.Image == chuki2_spp.Properties.Resources.no_photo is not true. You are comparing two different objects despite they are holding "the same" image.
Consider using flag to determine if Image was changed or not.
Upvotes: 1