Sending XML Image

Discussion in 'ASP .Net' started by Rob T, Jun 24, 2004.

  1. Rob T

    Rob T Guest

    Hi, I'm trying to send an image over XML. My routine gets the name, then
    gets the image out of a SQL database. This part works fine... but the XML
    returns the object, I get the following error: "System.Drawing.Bitmap
    cannot be serialized because it does not have a default public constructor."

    Here is a sample of the code:
    <WebMethod(Description:="Send Image")> Public Function SendImage(ByVal
    ImageName As String) As Object
    Dim strSQL As String 'text SQL statement
    Dim cmdSQL As SqlCommand 'SQL command

    cnnCUS = New SqlConnection(strCUS)

    strSQL = "select Img, ImgType from FormImg where ImgName='" & ImageName
    & "'"
    cmdSQL = New SqlCommand(strSQL, cnnCUS)
    cnnCUS.Open()
    SendImage = System.Drawing.Bitmap.FromStream(New
    System.IO.MemoryStream(CType(cmdSQL.ExecuteScalar, Byte())))
    cnnCUS.Close()

    End Function


    The code that calls the XML is something like this:

    Dim Im as bitmap
    Dim service As New XMLPrinter.xml_login()
    Im = service.SendImage("myImage")

    Thanks. -Rob T
     
    Rob T, Jun 24, 2004
    #1
    1. Advertising

  2. Rob T

    Rob T Guest

    Nevermind...I stored the info in a dataset and set it on its merry way.


    "Rob T" <> wrote in message
    news:...
    > Hi, I'm trying to send an image over XML. My routine gets the name, then
    > gets the image out of a SQL database. This part works fine... but the

    XML
    > returns the object, I get the following error: "System.Drawing.Bitmap
    > cannot be serialized because it does not have a default public

    constructor."
    >
    > Here is a sample of the code:
    > <WebMethod(Description:="Send Image")> Public Function SendImage(ByVal
    > ImageName As String) As Object
    > Dim strSQL As String 'text SQL statement
    > Dim cmdSQL As SqlCommand 'SQL command
    >
    > cnnCUS = New SqlConnection(strCUS)
    >
    > strSQL = "select Img, ImgType from FormImg where ImgName='" &

    ImageName
    > & "'"
    > cmdSQL = New SqlCommand(strSQL, cnnCUS)
    > cnnCUS.Open()
    > SendImage = System.Drawing.Bitmap.FromStream(New
    > System.IO.MemoryStream(CType(cmdSQL.ExecuteScalar, Byte())))
    > cnnCUS.Close()
    >
    > End Function
    >
    >
    > The code that calls the XML is something like this:
    >
    > Dim Im as bitmap
    > Dim service As New XMLPrinter.xml_login()
    > Im = service.SendImage("myImage")
    >
    > Thanks. -Rob T
    >
    >
     
    Rob T, Jun 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ersin Gençtürk

    sending inline image in email via .net smtp mail

    Ersin Gençtürk, Feb 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,016
    bruce barker
    Feb 28, 2005
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,416
    Kartic
    Jan 26, 2005
  3. Replies:
    0
    Views:
    1,441
  4. Luke
    Replies:
    2
    Views:
    4,780
    Nigel Wade
    Mar 15, 2007
  5. Erik Wasser
    Replies:
    5
    Views:
    495
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page