Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

inserting a Ole Object into a MS database

Posted on 2008-10-10
3
Medium Priority
?
330 Views
Last Modified: 2013-12-17
I'm inserting a record in a MS-access database.   I'm inserting an Oleobject with this sentence

cmd2.Parameters.Add("@FileData", OleDbType.    ).Value = Buffer;

Buffer is declared like this and holds data of a file:
 
byte[] Buffer

I'm having trouble declaring the type of the data  in Buffer   in  the Add sentence

Does anyone know how to declare this.

I put a part of the code here by.

string strConn2 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + GetConnectionString2();
 
                //string strSQL2 = "INSERT into Fylgiskjol (umsoknarnumer,Fylgiskjal,FileName ,FileSize,ContentType,FileData,Dags) values(?,?,?,?,?,?,?)";
                string strSQL2 = "INSERT into Fylgiskjol (umsoknarnumer,Fylgiskjal,FileName ,FileSize,ContentType,Dags) values(?,?,?,?,?,?)";
                OleDbConnection conn2 = new OleDbConnection(strConn2);
                conn2.Open();
 
                OleDbCommand cmd2 = new OleDbCommand();
 
                cmd2 = new OleDbCommand(strSQL2, conn2);
 
                int nFileLen = 0; 
                int iSkjalNumer = 0;
                byte[] Buffer = new byte[nFileLen];
                string strFilename = ""; 
				
                string strType = "";  
                string strName = "";
 
                AthFylgiskjalGlobalBreytur(ref iTeljari, ref nFileLen, ref iSkjalNumer, ref Buffer, ref strFilename, ref strType, ref strName);
                // ref strFilenameXmlMedPath,  ath hvað á að gera við þessa breytu 
                
                //			
                AthHvortApplErTil(iTeljari, nFileLen, iSkjalNumer, Buffer, strFilename, strType, strName);
				
                if( nFileLen > 0 )
                {
                    // Create new row                    cmd2.Parameters.Add("@umsoknarnumer",OleDbType.Integer).Value = Convert.ToInt64(nFileID);
                    cmd2.Parameters.Add("@Fylgiskjal",OleDbType.Char, 1).Value = strName;
                    cmd2.Parameters.Add("@FileName",OleDbType.Char, 255).Value = strFilename;
                    cmd2.Parameters.Add("@FileSize",OleDbType.Integer).Value = Convert.ToInt64(Buffer.Length);
                    cmd2.Parameters.Add("@ContentType",OleDbType.Char, 100).Value = strType;
                cmd.Parameters.Add("@FileData", OleDbType.BSTR).Value = Buffer;
                    cmd2.Parameters.Add("@Dags",OleDbType.Date).Value =  DateTime.Today;
 
                    cmd2.ExecuteNonQuery();

Open in new window

0
Comment
Question by:bjorkn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 2000 total points
ID: 22747296
See this link:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_10031039.html

Leban's free code utilities are usually better than ones that you can do on your own, so try free code and instructions provided with Leban's LoadSaveJpeg at this link:
http://www.lebans.com/loadsavejpeg.htm

HTH
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question