|
-
March 9th, 2010, 05:53 PM
#1
Retrieve image from SQL Server Database
Hello all
I want to read the byte data I have stored in a database which represents an image. I then want to apply this image as the picture of a Contact in Outlook. I am trying to use the getBytes() method but I am unsure of how to do this.
I have the code below so far.
'folder' is a custom folder I have created in Outlook separately. It stores the contacts.
Outlook.ContactItem newContact =
(Outlook.ContactItem)folder.Items.Add
(Outlook.OlItemType.olContactItem);
newContact.Attachments = reader.GetBytes(<some parameters to be added>);
any help is much appreciated
-
March 10th, 2010, 12:16 AM
#2
Re: Retrieve image from SQL Server Database
You have used an instance of an object called 'reader', but you do not state what class that object is...?
Also your code seems to have nothing to do with the title of the thread?
Have you gotten the image from the SQL database or is it that bit you are having problems with? If you are, can you show us that bit of code please.
Can you put your code inside code tags please.
Last edited by rliq; March 10th, 2010 at 12:19 AM.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
March 10th, 2010, 07:50 PM
#3
Re: Retrieve image from SQL Server Database
 Originally Posted by rliq
You have used an instance of an object called 'reader', but you do not state what class that object is...?
Also your code seems to have nothing to do with the title of the thread?
Have you gotten the image from the SQL database or is it that bit you are having problems with? If you are, can you show us that bit of code please.
Can you put your code inside code tags please.
Sorry the code I put was an old version that does not work...
What I wish to do is retrieve an image i have stored in a SQL Server database and then save it.
I have read the file into the database into an Image field with the fieldtype set to "Image". Upon entering the image the field reads <binary data>, showing that something is there.
How do I get images back from a database?
-
March 10th, 2010, 10:39 PM
#4
Re: Retrieve image from SQL Server Database
In VStudio within Server Explorer, create a DataConnection to your database.
In VStudio within Solution Explorer Add a Dataset.
Expand you DataConnection and drag the table onto your Dataset's design surface.
I assume your table has an Image type column in it containing your image.
Then look up an example of how to read a row from and SQL database into your Dataset/Table (sorry I'm not in a position to write one right now). Then use:
File.WriteAllBytes(/* filename */, /* data */);
Where the data is the Byte[] field from the DataTable in the Dataset.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|