Showing posts with label broken. Show all posts
Showing posts with label broken. Show all posts

Thursday, March 29, 2012

Deafult data for Image field

Hi,

I am storing my upoaded images in sql server. However, if the user does not upload an image, a broken link is shown in the page.
All that shows up in the DB field is <Binary>.

Can we set this field to a default value?
Is it possible to view this binary data.

I would like a default blank gif to be returned if no image is uploaded.

Regards,
JBISNULL(yourField, @.Default) ? I rarely use the image field, so i'm not sure if this works.|||What if an image is removed at a later date? What would you like to display then?

My gut feeling is that it would be best to not handle this through the database, but through one of your business objects.

With the database, you can make use of the ISNULL, but you cannot use an image data type for a local variable, so KraGiE's suggestion won't work as written. I was messing around with the NorthWind database and came up with this sort of thing:


-- this is for testing, should have a default photo sitting in a table somewhere and that table should be used instead of the @.myTest table
DECLARE @.myTest table (DefaultPhoto image)
INSERT INTO @.myTest SELECT photo from employees WHERE employeeID = 1

SELECT
photo,
DefaultPhoto,
ISNULL(photo,DefaultPhoto) AS DisplayPhoto
FROM
employees
LEFT OUTER JOIN
@.myTest ON employees.photo IS NULL


I'm sure there are 100 better ways to do this :-)

Terri|||ISNULL(Photo, SELECT Photo From Employees Where EmployeeID = @.DefaultPhotoID)

:)

Sunday, February 19, 2012

dbo puzzle

Hi,

I managed to get things broken and I can't solve it:

Scenario:
SQL Server
>Databases
>TestDB
> Users
> dbo mapped to user1 (user1 = SQL Server user)
> user1(database user) mapped to nothing (no SQL user)
->Security
-> Logins
-> user1

Problem: I don't want SQL Server user 'user1' to be dbo but I can't remove dbo rights because it owns objects nor can I drop database user 'user1' or delete SQL Server user 'user1' because it's mapped to dbo.

I'm running in circles..
First and last time I use the auto_fix option to fix orphaned users.
At this point, the only solution to me is dropping the database.

Anyone with a better idea?

Thank you!
Best Regards,
Worf

Have you tried these steps, in this order?

1. Create another user, User2

2. Add User2 to db_creator role

3. Transfer ownership of each object owned by User1 to User2

4. Remove dbo rights from User1

5. Remove User1 from db_owner role

6. Remove User1 from sysadmin role

7. Transfer ownership of each object owned by user2 to dbo

8. Remove User2 from db_creator role

9. Remove User2

10. Remove User1 if desired.

|||

which version of sql server is this? i believe SQL Server 2005. in that case this user1 might be owner of schema User1 and USER1 schema is the owner of objects. what need to do is change the owner of schema by


ALTER AUTHORIZATION ON SCHEMA::[User1] TO [dbo or whichever schema u want to transfer]

then drop the user

Madhu