Solved

Import Image into SQL Image Field Vb.Net

Posted on 2009-05-15
5
339 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
send messages to whatsapp programatically 2 65
vb.net help 4 34
VB.Net WebRequest Code from JSON curl 7 51
vb.net 1 month apart 11 35
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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