help regarding Inserting image in ORACLE Database using OLEDB in C#

Jul 28 2006 9:00 AM

plz help. I m inserting Images in Databse using OLEDB.
i designed a table with column names CAMPAIGN_ID,CREATION_DATE, CREATED_BY, CONTACT_COUNT, CAMPAIGN_NAME, CAMPAIGN_PHOTOGRAPH.

CAMPAIGN_PHOTOGRAPH this is BLOB field( which support 4GB size data), in which I have to insert Image.

i have write down code below.

I m geting error either
ORA-03113: end of file on communication chanel for some images

or ORA-01401: inserted value too large for column if selected some other image

Plz help.its urgent.


private void btnbrowse_Click(object sender,System.EventArgs e)
{
try
{
FileDialog fldlg=new OpenFileDialog();
fldlg.Filter="All Image Files(*.Tif;*.Bmp;*.Jpg;*.Gif;*Png)|*.Tif;*.Bmp;*.Jpg;*.Gif;*.Png";
fldlg.InitialDirectory=@"C\:";
if(fldlg.ShowDialog()==DialogResult.OK)
{
//imagename is string variable imagename=fldlg.FileName;
Bitmap newimg=new Bitmap(imagename);
pctimg.SizeMode=PictureBoxSizeMode.StretchImage;
pctimg.Image=(Image)newimg;
//txtName is TextBox which shows path of image file txtName.Text=String.Empty;
txtName.Text=imagename;
}
fldlg=null;
}
catch(Exception ee)
{
imagename="";
MessageBox.Show(ee.Message.ToString());
}
}

//save btton to insert image in database
private void btnsave_Click(object sender, System.EventArgs e)
{
try
{
if(imagename!="")
{
FileStream fls=new FileStream(@imagename,FileMode.Open,FileAccess.Read);
byte[] blob=new byte[fls.Length];
MessageBox.Show(blob.Length.ToString());
fls.Read(blob,0,Convert.ToInt32(fls.Length));
fls.Close();
connstr=System.Configuration.ConfigurationSettings.AppSettings["Mailer"];
conn=new OleDbConnection(connstr);
conn.Open();


String dt;
dt=txtDate.Text;





query="insert into CAMPAIGN_DETAILS (CAMPAIGN_ID,CREATION_DATE, CREATED_BY,CONTACT_COUNT, CAMPAIGN_NAME, CAMPAIGN_PHOTOGRAPH) values(" + id + ",'" + dt + "'," + Int32.Parse(txtDesigner.Text)+ "," + id + ",'" + txtName.Text + "',?)";
cmd=new OleDbCommand(query,conn);

OleDbParameter binParameter =new OleDbParameter();
binParameter.Value=blob;
binParameter.Size=fls.Length;
binParameter.OleDbType=OleDbType.Binary;
binParameter.ParameterName="@CAMPAIGN_PHOTOGRAPH";
cmd.Parameters.Add(binParameter);

cmd.ExecuteNonQuery();






}
}
catch( OleDbException ex)
{
MessageBox.Show(ex.Message);

}
finally
{
cmd.Dispose();
conn.Dispose();
}
}

Pawan Kumar Dubey