?
Solved

Import Image into SQL Image Field Vb.Net

Posted on 2009-05-15
5
Medium Priority
?
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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