Solved

Import Image into SQL Image Field Vb.Net

Posted on 2009-05-15
5
341 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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