Import Image into SQL Image Field Vb.Net


I'm Importing an XML file into SQL but one of the elements in the XML file contains an image and I'm wondering how to do that.  Here's some of my code, although it's wrong but I'm just wondering how to handle the image.


Dim cm As SqlCommand
Dim objCon As SqlConnection = New SqlConnection(sConnection)
cm = New SqlCommand("usp_addXML", objCon)
cm.CommandType = CommandType.StoredProcedure
Dim pID As SqlParameter = New SqlParameter("@ID", SqlDbType.BigInt, 100)
Dim pPhotograph As SqlParameter = New SqlParameter("@Photograph", SqlDbType.Image)
While myNodeText.MoveNext()
    Select Case myNodeText.Current.Name
        Case "ID"
            pID.Value = iCount
        Case "Photograph"
            pPhotograph.Value = myNodeText.Current.Value
    End Select
The line pOffencePhotograph.Value = myNodeText.Current.Value is obviously trying to pass a string, so I need to convert it to an image.  Thanks in advance.

Open in new window

Who is Participating?
DhaestConnect With a Mentor Commented:
Or do you mean without an external application (like atalasoft)

CodeSnip: How to Read/Write an Image to Database in Binary Format

Get Image from DB table and show it

Save/Retrieve Image From SQL Server Database Using Ado 2.5 Stream Object

Other usefull resources 
Save An Image Into SQL Server 2000 Database

HOWTO: Read and write images from a database using SQL Server
lee_murphyAuthor Commented:
Thanks Dhaest, the first example I beleive requires me to create a file from the data first.  The second doesn't but that requires me to purchase something.  Is there a way of importing it without saving it to an external file, and without buying some add-on?
>> without saving it to an external

I have never seen it before (and saw the same question alot)
lee_murphyAuthor Commented:
Got it to work saving to a file and then importing that.  Thanks for your help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.