Solved

inserting a Ole Object into a MS database

Posted on 2008-10-10
3
324 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
3 Comments
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 500 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

749 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