none
Error {"ORA-01008: not all variables bound"} when uploading files in oracle database using C# RRS feed

  • Question

  • Hi,
    I am getting error when uploading the files in oracle database.........
    My code is as below..
    for (int i = 0; i < Attachment.Length-1; i++)
                    {                    
                        byte[] MailAttachment = ReadFile(Attachment[i]);                   
                        if (MailAttachment != null)
                        {                        
                            string FileName = Attachment[i].ToString();
                            string[] splitFileName = FileName.Split(new Char [] {'\\'});
                            FileName = splitFileName[splitFileName.Length - 1];
                            string eMailAttachmentQuerry = "Insert into eMailAttachment(sNo, ServiceID,FileName, Attachment,SendDateTime)" +
                                                                            "values(:Sno,:ServiceID,:FileName, :Attachment,:SendDateTime)";
                            OleDbCommand cmdEmailAttachment = new OleDbCommand(eMailAttachmentQuerry, conn, transaction);
    
                            cmdEmailAttachment.Parameters.Add(new OleDbParameter(":Sno", serviceID));
                            cmdEmailAttachment.Parameters.Add(new OleDbParameter(":ServiceID", serviceID));
                            cmdEmailAttachment.Parameters.Add(new OleDbParameter(":FileName", FileName));
                            cmdEmailAttachment.Parameters.Add(new OleDbParameter(":Attachment", (object)ReadFile(Attachment[i])));
                            cmdEmailAttachment.Parameters.Add(new OleDbParameter(":SendDateTime", System.DateTime.Now));
                            cmdEmailAttachment.ExecuteNonQuery();
                        }
                    } 
    private byte[] ReadFile(string sPath)
            {
                byte[] data = null;
                try
                {
                    if (sPath == null || sPath == "")
                        return null;
                    FileInfo fInfo = new FileInfo(sPath);
                    long numBytes = fInfo.Length;
                    FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
    
                    BinaryReader br = new BinaryReader(fStream);
                    data = br.ReadBytes((int)numBytes);
                    return data;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }        
    Error is:
    {"ORA-01008: not all variables bound"}



    Prakash
    • Moved by Harry Zhu Monday, June 29, 2009 3:44 AM relating to data provider (From:Visual C# Language)
    Friday, June 26, 2009 4:17 AM

All replies

  • Hi All,

    I got the alternate solution.
    By using Oracle Command it is working fine.
    for (int i = 0; i < Attachment.Length-1; i++)
                    {                    
                        byte[] MailAttachment = ReadFile(Attachment[i]);                   
                        if (MailAttachment != null)
                        {                        
                            string FileName = Attachment[i].ToString();
                            string[] splitFileName = FileName.Split(new Char [] {'\\'});
                            FileName = splitFileName[splitFileName.Length - 1];
                            string eMailAttachmentQuerry = "Insert into eMailAttachment(sNo, ServiceID,FileName, Attachment,SendDateTime)" +
                                                                            "values(:Sno,:ServiceID,:FileName, :Attachment,:SendDateTime)";
    
                            OracleCommand cmdEmailAttachment = new OracleCommand(eMailAttachmentQuerry, conn, transaction);
    
                            cmdEmailAttachment.Parameters.Add(new OracleParameter(":Sno", 5));
                            cmdEmailAttachment.Parameters.Add(new OracleParameter(":ServiceID", serviceID));
                            cmdEmailAttachment.Parameters.Add(new OracleParameter(":FileName", FileName));
                            cmdEmailAttachment.Parameters.Add(new OracleParameter(":Attachment", (object)ReadFile(Attachment[i])));
                            cmdEmailAttachment.Parameters.Add(new OracleParameter(":SendDateTime", System.DateTime.Now));
                            cmdEmailAttachment.ExecuteNonQuery();
                        }
                    } 

    But why it not working with OLEDB??

    Prakash
    Friday, June 26, 2009 5:24 AM
  • Perhaps the OleDb command doesn't recognize parameters that begin with ":".
    Friday, June 26, 2009 3:29 PM
  • I had tried @ also but same problem.
    Prakash
    Tuesday, June 30, 2009 6:42 AM