Solved

Import Image into SQL Image Field Vb.Net

Posted on 2009-05-15
5
331 Views
Last Modified: 2012-05-07
Hi,

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.

Thanks

Lee
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

            cm.Parameters.Add(pID)

        Case "Photograph"

            pPhotograph.Value = myNodeText.Current.Value

            cm.Parameters.Add(pPhotograph)

    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

0
Comment
Question by:lee_murphy
  • 3
  • 2
5 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24394786
Save An Image Into SQL Server 2000 Database
http://www.codeproject.com/KB/web-image/PicManager.aspx

HOWTO: Read and write images from a database using SQL Server
http://www.atalasoft.com/KB/Article.aspx?id=10018
0
 

Author Comment

by:lee_murphy
ID: 24394891
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?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24394905
>> without saving it to an external

I have never seen it before (and saw the same question alot)
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 24394923
Or do you mean without an external application (like atalasoft)

CodeSnip: How to Read/Write an Image to Database in Binary Format
http://aspalliance.com/1083_codesnip_how_to_readwrite_an_image_to_database_in_binary_format

Get Image from DB table and show it
http://www.codeproject.com/KB/database/images2db.aspx

Save/Retrieve Image From SQL Server Database Using Ado 2.5 Stream Object
http://www.freevbcode.com/ShowCode.Asp?ID=1802

Other usefull resources
http://www.stardeveloper.com/articles/display.html?article=2001033101&page=1
http://www.carobit.com/ShowThread/Visual%20Basic/20021128112520Rem.html
0
 

Author Closing Comment

by:lee_murphy
ID: 31581885
Got it to work saving to a file and then importing that.  Thanks for your help
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now