473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inserting a blob from a file

Everytime I try to inset a blob from a file I get the following error.
ORA-12571: TNS:packet writer failure.

I was able to successful insert a blob from a post to another another
page using the PostedFile object. But for some reason this will not
work for a file.

Below is the code that I tried:

// provide read access to the file
FileStream fs = new FileStream(newFileName,
FileMode.Open,FileAccess.Read);

// Create a byte array of file stream length
byte[] newFileBuf = new byte[fs.Length];
fs.Read(newFileBuf,0,System.Convert.ToInt32(fs.Len gth));
//Close the File Stream
fs.Close();

try
{
OleDbConnection cn = new OleDbConnection(strConnect);
OleDbCommand cmd = new OleDbCommand("INSERT INTO TESTBLOB
(NewFile,ID) VALUES (?, 1)", cn);

OleDbParameter prm1 = new OleDbParameter("@NewFile",
OleDbType.LongVarBinary, newFileBuf.Length, ParameterDirection.Input,
false, 0, 0,null, DataRowVersion.Current, newFileBuf);
cmd.Parameters.Add(prm1);

cn.Open();
cmd.ExecuteNonQuery();

cn.Close();
}
catch(Exception ex)
{
label1.Text = ex.Message;
}
when I use replace the top with this:

Stream myStream = Invoice.PostedFile.InputStream;
byte[] newFileBuf= new byte[Invoice.PostedFile.ContentLength];
myStream.Read(newFileBuf, 0, Invoice.PostedFile.ContentLength);
Nov 16 '05 #1
0 1176

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising...
3
by: ketulp_baroda | last post by:
Hi I am storing the attachment in the database. For some file the data gets stored in the database but for other files it gives a MySql error. For eg. when I am trying to attach the file foo.txtit...
1
by: Nathan Sokalski | last post by:
I am writing an SQL script for Oracle 9i. I have a table of which one field is of type BLOB. I would like to create an SQL script to add records to this table. What do I do to take a file and use...
0
by: Paul Kennedy | last post by:
I have a situation where I am utilizing code from MSDN to insert XLS files into a Microsoft Access Table in a column of Ole Object using VBA and DAO. That code also provides me with a method to...
0
by: Scott B | last post by:
This may or may not have been answered before, and I have googled to death on it and I am not getting any good answers. So here it is: I am trying to update some blob data in an MS Access DB. ...
0
by: Harshadcode | last post by:
Hi, This is HARSHAD, I am creating a project in VB.NET for managing details like photos of criminals. but i am facing problems in converting a image in to filestream so that it can be inserted in...
11
by: krishnakant Mane | last post by:
hello, I finally got some code to push a pickled list into a database table. but now the problem is technically complex although possible to solve. the problem is that I can nicely pickle and...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.