I had a database table which stores an event image. I have a column called ImageName which stores image name. Now problem was, when i upload an image with new event, and then update something other than an event image, it was set back to null.
That was because, the update query sent to the stored procedure was like that, so this can be solved in many ways, but the minimum change way is this one:
Update Events
set
column1 = @column1Value,
column2 = @column2Value,
column3 = @column3Value,
ImageName = isnull(@imageName,imageName),
[ where condition goes here]
Nice fix, I know generally people choose front end way to pass proper data, but this one is also nice one
No comments:
Post a Comment
Please add your valuable comments about this post if it helped you. Thanks