What is the best way to import a image to sql server

  • Hi,

    I want to give users the ability to import images from a excel spread sheet to a sql server database.. I know you i can import the data by using sqlbulkcopy and it works fine...

    We wanted to add logos for our reporting system so I wanted to know if there is a way we can get the images from a excel file to sql server... and what is the best way to do it...

    Any help will be appreciated.

    Thanks,

    Karen

  • ouch...that is a hard one.

    I think you are saying you have an excel spreadsheet that contains embedded images. say someone pasted half a dozen images into an excel worksheet, and now you want to extract them, right?

    you'd HAVE to do this in an application by automating Excel, which I never had a good time doing.

    There's an example of putting images into an excel document here:http://www.codeproject.com/KB/COM/ComExcelImages.aspx?display=Print

    if you look at the code, there is a collection called CPictures; to extract images you'd look thru the collection for each image and extract them.

    if this is a one time extraction, i'd make soneone copy/paste from excel to photshop/paintshop and save the images.

    only if this was going to be a regualr thing would i consider writing an application, and I doubt it woudl be worth your while to try to use a COM interface from within any TSQL code to try and extract the images....

    writing an application to extract the images, and then using tsql to run the app and harvest the images from some file folder probablt would not be too difficut.

    Karen Roslund (11/18/2008)


    Hi,

    I want to give users the ability to import images from a excel spread sheet to a sql server database.. I know you i can import the data by using sqlbulkcopy and it works fine...

    We wanted to add logos for our reporting system so I wanted to know if there is a way we can get the images from a excel file to sql server... and what is the best way to do it...

    Any help will be appreciated.

    Thanks,

    Karen

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for the quick reply.. my spread sheet has the following columns and everything is done on a plan level.. so my spread sheet with the logo information will look like this

    PlanId ContactInfo PhoneInfo MEssageBoard Logo

    01212 whtver 7845455 message Picture

    and u can have n rows in the spread sheet.. but the problem i think i would run into .. is in excel if i had a picture in a spreadsheet it doesnt put it in a cell so how would i know for which plan or which row does the image belong too..

    do u have any other ideas as to what can be done..

    thanks,

    Karen

  • How many images are there?

    Are these images stored on a drive anywhere?

  • Are you using Excel 2008? If so there is a table function. Where you can make your xlsx into a table. Then you can in bed the picture into a row. Will that work?

  • The client is going to provide us the excel spread sheet...but we wanted to add a logo as a new feature so i thought to just put them in the existing template..

    I am thinking that once the picture is on excel spread i can run a script (if one exists) to copy the picture to whereever and then store the path or image itself in sql server

    As for the no's of images... it depends on how many plans the client has?

    We are using EXcel 2003.. havent used xlsx yet.. cause most of our client dont recognise that format..

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply