Load a image from sqlce

H

Henrik

Hallo



I have a sqlce database whit some image, how do I get the image from the
sqlce database to the picturebox?



I have search a lot on the internet, whit out finding some sing, that I cut
get works L



This is the code I work whit:

Dim cn As System.Data.SqlServerCe.SqlCeConnection = New
System.Data.SqlServerCe.SqlCeConnection("Data Source=SD Card\My
Documents\Scubase.sdf")

Dim cmd As New System.Data.SqlServerCe.SqlCeCommand 'Option

Dim da As System.Data.SqlServerCe.SqlCeDataAdapter 'Option

Dim dt As System.Data.DataTable = New
System.Data.DataTable("PicturesOrganism") 'Option

cn.Open()

cmd.CommandText = "SELECT * FROM PicturesOrganism"

cmd.Connection = cn

da = New System.Data.SqlServerCe.SqlCeDataAdapter(cmd)

da.Fill(dt)

Label1.DataBindings.Add(New Binding("Text", dt, "PictureName"))
 
H

Henrik

I' am Sorry, but I can't not, get it to work L

Can some one, show me some VB.Net CF code?

I am new I programming vb.net L



Henrik
 
S

Simon Hart

Show us your code so far including setting the image and returning it.

Cheers
Simon.
 
H

Henrik

I only have the code, I am using to get some, text field out of the
database.

I hope that some one, cut help me farther whit the code I have, or if some
one

cut send me an example, where I cut see how it shut be don.



Henrik



My code:



Dim cn As System.Data.SqlServerCe.SqlCeConnection = New
System.Data.SqlServerCe.SqlCeConnection("Data Source=SD Card\My
Documents\Scubase.sdf")

Dim cmd As New System.Data.SqlServerCe.SqlCeCommand 'Option

Dim da As System.Data.SqlServerCe.SqlCeDataAdapter 'Option

Dim dt As System.Data.DataTable = New
System.Data.DataTable("PicturesOrganism") 'Option

cn.Open()

cmd.CommandText = "SELECT * FROM PicturesOrganism"

cmd.Connection = cn

da = New System.Data.SqlServerCe.SqlCeDataAdapter(cmd)

da.Fill(dt)

Label1.DataBindings.Add(New Binding("Text", dt, "PictureName"))
 
S

Simon Hart

I must admit I struggled to achieve this under CF mainly because of
limitations in place.

So instead I changed my SQL CE image data type to ntext and saved the byte
array of the image as a base64 string. Of course if you are using images of
great size then it is not recommended to store these in SQL CE as you will
soon run out of memory when trying to execute ADO.NET instructions.

Alternatively try posting a question here:
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=152&SiteID=1

Cheers
Simon.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top