1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Problem in uploading files to Oracle database using blob

Discussion in 'Oracle' started by rashmi_s, Jan 21, 2010.

  1. rashmi_s

    rashmi_s New Member

    While retrieving an uploaded file from oracle database, junk characters are displayed at the start & end of the uploaded content. Also it does not show every line. Part of the code can be found below. Can anyone help or has some different solution??

    Upload.aspx.cs (Upload file code)

    filename = filMyFile.PostedFile.FileName;
    FileStream fls;
    fls = new FileStream(filename, FileMode.Open, FileAccess.Read);
    blob = new byte[fls.Length];
    fls.Read(blob, 0, System.Convert.ToInt32(fls.Length));
    query = "insert into poemmaster values(" + pid + ",'" + txtTitle.Text + "'," + " :BlobParameter," +uid+",'"+ ddlCategory.SelectedValue.ToString() + "',default)";
    OracleParameter blobParameter = new OracleParameter();
    blobParameter.OracleType = OracleType.Blob;
    blobParameter.ParameterName = "BlobParameter";
    blobParameter.Value = blob;
    cmnd = new OracleCommand(query, conn1);
    Retrieve.aspx.cs(Retrieve file code)

    FileStream FS = new FileStream("word.doc", FileMode.Create);
    foreach (DataRow dr in dt.Rows)
    lblPoemName.Text = dr[1].ToString();
    byte[] blob = (byte[])dr[2];
    lblCategory.Text = dr[4].ToString();
    lblFName.Text = dr[7].ToString();
    lblLName.Text = dr[8].ToString();
    FS.Write(blob, 0, blob.Length);
    FileStream fs2 = new FileStream("word.doc", FileMode.Open, FileAccess.Read);
    StreamReader sReader2 = new StreamReader(fs2, System.Text.Encoding.Default);
    line = sReader2.ReadLine();
    while ((line = sReader2.ReadLine()) != null)
    txtTitle.Text = txtTitle.Text + "\r\n" + sReader2.ReadLine();

Share This Page