Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:44:53+00:00 2026-05-16T02:44:53+00:00

Such a simple task: How to store a Byte[] in Access 2010? (Searching the

  • 0

Such a simple task: How to store a Byte[] in Access 2010? (Searching the web all day long about this.)

I have to use a “Attachment Field” in access 2010 because as far as i can see there is no other possible (varBinary, Image,..) field available.

I tried: (ConvertImageToByte returns a Byte[])

 Cmd.CommandText = "UPDATE Clubs SET Field1 = @File WHERE Name = @Name";
 OleDbParameter para = new OleDbParameter("@File", OleDbType.VarBinary);
 para.Value = ConvertImageToByte(Logo);
 Cmd.ExecuteNonQuery();

Exception: “An UPDATE or DELETE query cannot contain a multi-valued field.”

I tried:

 DBEngine dbe = new DBEngine();
 Database db = dbe.OpenDatabase("database.accdb", false, false, "");
 String Command = "SELECT * FROM Clubs";
 Recordset rs = db.OpenRecordset(Command, RecordsetTypeEnum.dbOpenDynaset, 0, LockTypeEnum.dbOptimistic);
 rs.MoveFirst();
 rs.Edit();
 Recordset2 rs2 = (Recordset2)rs.Fields["Field1"].Value;
 rs2.AddNew();

 Field2 f2 = (Field2)rs2.Fields["FileData"];


 f2.LoadFromFile("file.png");
 rs2._30_Update();
 rs2.Close();

 rs._30_Update();
 rs.Close();

This works but the file is in the first row of the tabel all the time and i can´t figure out how to get the right row. If i try to add a WHERE clause to the SELECT statement ill get a ” Too few parameters. Expected 2.” exception.

If anyone knows a way to story my Byte[] (or a image) into the database an get it out again please let me know!

Please don´t give me links to:

http://office.microsoft.com/en-us/access-help/using-multivalued-fields-in-queries-HA010149297.aspx#BM4.6

http://www.mikesdotnetting.com/Article/123/Storing-Files-and-Images-in-Access-with-ASP.NET

http://www.sitepoint.com/forums/showthread.php?t=666928

http://www.eggheadcafe.com/software/aspnet/35103540/multivalued-fields-in-access-2007-with-c-ado.aspx

Programmatically managing Microsoft Access Attachment-typed field with .NET

Thanks for your help guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:44:54+00:00Added an answer on May 16, 2026 at 2:44 am

    You can use an OLE Object field, it is the best choice for varbinary(max) match up.

    Some notes:

    ''Reference: Microsoft ActiveX Data Object x.x Library
    Dim strSQL As String
    Dim strCN As String
    Dim rs As dao.Recordset
    Dim mstream As ADODB.Stream
    
    
    strSQL = "SELECT Pix FROM Table1"
    Set rs = CurrentDb.OpenRecordset(strSQL)
    
    Set mstream = New ADODB.Stream
    mstream.Type = adTypeBinary
    mstream.Open
    mstream.LoadFromFile "c:\docs\project.jpg" ''FileName & FullPath
    
    rs.AddNew
    rs.Fields("Pix").Value = mstream.Read
    rs.Update
    
    rs.Close
    

    EDIT

    To copy back to disk, you can again use the Stream:

    Dim strSQL As String
    Dim cn As New ADODB.Connection
    Dim mstream As New ADODB.Stream
    
    
    strSQL = "SELECT Pix FROM Table1"
    Set rs = CurrentDb.OpenRecordset(strSQL)
    
    mstream.Type = adTypeBinary
    mstream.Open
    mstream.Write rs!Pix
    mstream.SaveToFile "c:\docs\pixout.jpg", adSaveCreateOverWrite
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like such a simple question. I have several Edit boxes on my
Math has defeated me once again. This is such a simple task, but I
This seems like such a simple task, but I'm having a hard time finding
Okay, I have no idea how to do this simple thing. All I need
This seems like such a simple task, yet I am unable to find a
This seems like such a simple issue but I cannot find an elegant solution.
This is such a simple problem, but I can't find an answer anywhere... I
this must be such a simple problem but can someone tell me why this
sorry this is such a simple question but I can't figure it out. How
I have a java web application based on Spring MVC. The task is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.