Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Bilddtaen vom Typ: image (SQL-Server) in PictureBox.Image anzeigen
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joerg Trumpfheller  
View profile   Translate to Translated (View Original)
 More options Jun 12 2012, 9:49 am
Newsgroups: de.comp.lang.dotnet.vb
From: Joerg Trumpfheller <joergtrumpfhel...@googlemail.com>
Date: Tue, 12 Jun 2012 06:49:52 -0700 (PDT)
Local: Tues, Jun 12 2012 9:49 am
Subject: Bilddtaen vom Typ: image (SQL-Server) in PictureBox.Image anzeigen
Bin langsam am verzweifeln. Habe auch schon viele threads gelesen und Lösungsvorschläge ausprobiert.
Folgendes Problem:
In einer SQL-Server Tabelle werden Bilder in einem Feld vom Data Type image (size 16) verwaltet (ich weiß, ist veraltet, aber damit muss ich erstmal arbeiten).
Dieses möchte ich gern in einer VB.NET-Form-PictureBox anzeigen lassen, hier über einen Button aufgerufen.

    Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
      getImageData("11000000")
    End Sub

    Private Sub getImageData(ByVal IN_ID As String)
        Dim conns as String = "Server=XXX007;DataBase=MyDB;Integrated Security=SSPI"
        dim m_CON1 as SqlConnection = New SqlConnection(conns)

        Dim ds As New DataSet
        Dim sqlString As String = "SELECT Bild FROM tbl_Bild WHERE(Bild_ID = " & IN_ID & ")"

        Dim cmd As New SqlCommand
        Dim da As SqlDataAdapter

        Try
            cmd.Connection = m_CON1
            cmd.CommandText = sqlString
            da = New SqlDataAdapter(cmd)
            da.Fill(ds, "MyBild")

            Dim i As Integer = ds.Tables("MyBild").Rows.Count
            If i > 0 Then

                ' Byte-Array mit den Daten befüllen
                Dim bytBLOBData() As Byte = CType(ds.Tables("MyBild").Rows(i - 1).Item(0), Byte())

                ' Per MemoryStream in die PictureBox bringen
                Dim stmBLOBData As New MemoryStream(bytBLOBData)
                PictureBox1.Image = Image.FromStream(stmBLOBData)

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            m_CON1.Close()
        End Try
    End Sub

bei PictureBox1.Image = Image.FromStream(stmBLOBData) schmiert das Programm immer ab mit der Fehlermeldung "Ungültiger Parameter": Eine Ausnahme (erste Chance) des Typs "System.ArgumentException" ist in System.Drawing.dll aufgetreten. Das Ergebnis im Dataset sagt, es handelt sich um ein Feld vom Typ System.Byte[].

Was mache ich falsch?

LG Jörg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Fleischer  
View profile   Translate to Translated (View Original)
 More options Jun 16 2012, 1:00 pm
Newsgroups: de.comp.lang.dotnet.vb
From: "Peter Fleischer" <peter.fleischer_nosp...@gmx.de>
Date: Sat, 16 Jun 2012 19:00:20 +0200
Local: Sat, Jun 16 2012 1:00 pm
Subject: Re: Bilddtaen vom Typ: image (SQL-Server) in PictureBox.Image anzeigen
Hi Jörg,
ich nutze die Erstellung eines Bitmap-Objektes, was in Deinem Code so
aussehen würde:

' ...
' anstelle:
' Dim stmBLOBData As New MemoryStream(bytBLOBData)
' PictureBox1.Image = Image.FromStream(stmBLOBData)
' die beiden folgenden Anweisungen:
Dim stmBLOBData As New System.IO.MemoryStream(bytBLOBData)
PictureBox1.Image = New Bitmap(stmBLOBData )
' ...

--
Viele Gruesse
Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joerg Trumpfheller  
View profile   Translate to Translated (View Original)
 More options Jul 4 2012, 11:07 am
Newsgroups: de.comp.lang.dotnet.vb
From: Joerg Trumpfheller <joergtrumpfhel...@googlemail.com>
Date: Wed, 4 Jul 2012 08:07:34 -0700 (PDT)
Local: Wed, Jul 4 2012 11:07 am
Subject: Re: Bilddtaen vom Typ: image (SQL-Server) in PictureBox.Image anzeigen
Am Samstag, 16. Juni 2012 19:00:20 UTC+2 schrieb Peter Fleischer:

Sorry, dass ich mich erst jetzt melde. Eine Bronchitis hat mich 2 Wochen niedergestreckt.
Hab Dein Beispiel ausprobiert, funktioniert aber leider auch nicht (gleiche Fehlermeldung).

Ich füge hier mal die ersten Zeilen der image-Daten an. Vielleicht sind dies ja keine Blob-Daten (kenne mich damit nicht so gut aus)

-- Start Bild --
0x151C1A00030000000500010014001900FFFFFFFF42696C640000010500000300000004000 000444942001F0D000004F4FFFF28AE0000280000007F0000007400000001001800000000 ... usw.
(Länge > 43.000 Zeichen)
-- Ende Bild --

Wie gesagt mit dem Microsoft SQL Server Management Studio (10.50.2500.0) wird diese Spalte angezeigt als
Data Type: image
System Type: image

Gruß Joerg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »