How to load images into SQL table

  • Hi,

    I don't know how to load images file into SQL column type image. Can anybody help. Thanks a lot for help in advance.

    Han,

  • This was removed by the editor as SPAM

  • Here is an example from BOL:

    Open SQL Query Analyzer, connect to an instance of SQL Server, and run the Createtb.sql query.

    Open a Command Prompt window and change the current directory to

    C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Utils\bii.

    Enter the following command (The -v option is optional; it displays current status.):

    bii testinsert.bii -Syourservername -Dyourdbname -Usqlusername -Psqlpassword -t, -v



    Bye
    Gabor

  • Sorry for the late post.

    Do you mean from TSQL or via teh front end eg VB.NET.

    In .NET the image datatype corresponds to a byte array.

    I once captured a web cam output into a byte array, then uploaded that to the server (part of a web app)

    To retrieve it, I set the SRC attribute of teh IMG tag to an aspx page that queried the database to get the image column.

  • Or try textcopy.exe command.

  • It depends what tool do you want to use to load an image. I load images into field of image data type but I use ODBC to do so. I use prepared statememt (i.e. insert IMAGES (IMAGE_COLUMN) values (?)) and SQLBindParameter to bind it with folowing flags

    SQL_PARAM_INPUT,

    SQL_C_BINARY,

    SQL_LONGVARBINARY

    and pass in a size of an image.

    Then I call SQLParamData in a loop while it returns SQL_NEED_DATA and put data in using SQLPutData.

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

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