473,516 Members | 3,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write ole object from access DB to file

1 New Member
I'm trying to read an ole object from my access database and save them as jpeg images to file.


Well at line:
"picture = Image.FromStream(stream)"

It keeps saying "Parameter is not valid." Does anyone know why?

Expand|Select|Wrap|Line Numbers
  1. Option Explicit On
  2. Imports System.IO
  3. Imports System.Data.OleDb
  4.  
  5. Public Class Form1
  6.     Private rs As ADODB.Recordset
  7.     Dim test As OleDb.OleDbDataReader
  8.     Dim RecCount As Integer
  9.     Dim format As String = ".Jpeg"
  10.     'Dim c As New cDibSection
  11.  
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & _
  14.                               "Data Source=C:\Database3.accdb")
  15.         cn.Open()
  16.         Dim Command As New OleDbCommand("SELECT * FROM Table1", cn)
  17.         Dim Reader As OleDbDataReader = Command.ExecuteReader()
  18.         Dim picture As Image = Nothing
  19.  
  20.         While Reader.Read
  21.             Dim pictureData As Byte() = CType(Reader.GetValue(2), Byte())
  22.  
  23.             Using stream As New IO.MemoryStream()
  24.                 picture = Image.FromStream(stream)
  25.                 stream.Write(pictureData, 78, pictureData.Length - 78)
  26.  
  27.             End Using
  28.  
  29.             My.Computer.Clipboard.SetImage(picture)
  30.             If My.Computer.Clipboard.ContainsImage() Then
  31.                 picture = My.Computer.Clipboard.GetImage
  32.                 picture.Save("C:\Image\lalala.jpg")
  33.             End If
  34.         End While
  35.         cn.Close()
  36.  
  37.     End Sub
  38.  
  39.     Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
  40.  
  41.     End Sub
  42. End Class
Mar 31 '11 #1
0 1235

Sign in to post your reply or Sign up for a free account.

Similar topics

18
6774
by: reclusive monkey | last post by:
Firstly is this possible?! I've been playing around with XML for various things, and it would be very helpful if I could manage to write to an XML file with no server-side work. The reason for this is simple; I work for a local council (UK), and thus I don't have access to anything server-side. I've read around various sites and most of the...
4
8291
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG: "Could Not Copy Temporary Files to the Output Directory" Error Message When You Build a Solution That Contains Multiple Projects I have tried all...
12
1966
by: facicad | last post by:
Look my prog. I have combobox where is have all tables names of access file. The user select one table and the content is show in datagrid. The user can add, erase or modify some record or row. Until now is ok but went I want to update access file, VB send me error. Some body can help me Dim myCnn As New OleDb.OleDbConnection Dim...
10
7380
by: Minh | last post by:
I search in all the Disscussion but can not found. How can I create a MS Access Database file using C# code with a given Table Structure ? For example, I want to create a Access Database File with 2 tables: Student and Department, of course, using C# code, not using MS Access to create manually. In Department table, I will have 3...
3
2344
by: VB.NET | last post by:
I'm using a mysql database and connecting my vb.net program to the DB over a network connection. i would like to bring this data over to a vb.net random access file. does anyone know how to convert my DB into a binary file? and how to convert my code to use a file instead of the db?
2
2899
by: Alan T | last post by:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="DataBaseConnection" connectionString="server=localhost;database=SalesDB;User
12
1902
by: Dr. Edmund M. Hayes | last post by:
I wrote a access program that works well enough that a handful of people would like to buy it from me. My problem is that if I sell it to someone there is no mechanism that I know of to protect them from giving it to anyone they feel like. The program produces reports that are specific to a particular organization but that does stop anyone...
4
1561
bluegreenisland
by: bluegreenisland | last post by:
Hi everyone, I am new to this, so am bound to make blunders ~just let me know & I'll correct them. I am hoping to learn how to write to a file, make changes to the data, and read. I have a class definition in a .h file, the member functions definitions in a .cpp file, and a driver program which has two functions besides main(): writeFile()...
2
11316
by: =?Utf-8?B?RGFtZW9u?= | last post by:
Hi - I am attempting to write lines to a file at high volume, multiple threads. Here is my scenario: (initial "WriteToFile" object created via a parent multithreaded process, which receives files, can call custom code for each file received - much like BizTalk) 1. Receive multiple files, each file received creates a "WriteToFile" object
1
3256
by: pauld | last post by:
Hello - I have created a simple web application in VS 2005/ASP.net 2.0 for a university department to track problems with a new website that I have built for them. The app consists of an Access 2003 db configured to use the aspnet role provider (via the "unreleased" Access Providers) and it also has a "bugs" table that stores the data...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.