title: C# ODBC Insert BLOB
body: <p>The code below works fine when connecting to a SQL Server, however it throws an exception when I try pointing it to an Oracle database. The exception returns a empty error message, so I'm not really sure what I should look at next. Any help would greatly appreciated. I did search before making this post and all the questions relating to oracle seemed to use the Oracle ADO methods and not ODBC.</p>
  
  <p>Here's the variable setting for the read_blob_file function below:</p>
  
  <pre><code>  string dbname = "oracle_odbc_database";
    string uid = "username";
    string pwd = "password";
    string sql = "INSERT INTO CD_ATTACHMENT (\"ATTACHMENT_ID\",\"DESCRIPTION\",\"ATTACHMENT\",\"CREATE_DATE\",\"MIME_TYPE\",\"CREATE_USER_ID\",\"CREATE_APP_ID\",\"UPDATE_DATE\",\"UPDATE_USER_ID\",\"UPDATE_APP_ID\") VALUES (''YPoem'','NULL',?,'to_date('10/8/2013 6:30:41 AM','MM/DD/YYYY HH:MI:SS AM')','NULL',''EFPUFC1B(AMERICAS\\EFPUFC1B)'',''OpenWells'','NULL','NULL','NULL');";
    string blob_value = "'c:\\ATTACHMENT\\00AfKOHF-ATTACHMENT.blob'";
    string blob_column = "ATTACHMENT";
  
  
  private int read_blob_file(string dbname, string uid, string pwd, string sql)
          {
              int rtncmd = -99;
              try
              {
                  using (var conn = new OdbcConnection("DSN=" + dbname + ";UID=" + uid + ";pwd=" + pwd))
                  {
                      conn.ConnectionTimeout = 1500;
                      conn.Open();
                      using (var cmd = conn.CreateCommand())
                      {
                          if (blob_value != "")
                          {
                              blob_value = blob_value.Replace("'","");
                              using (var inputStream = File.OpenRead(blob_value))
                              {
                                  cmd.Parameters.AddWithValue(blob_column, File.ReadAllBytes(blob_value));
                              }
                          }
                          cmd.CommandText = sql;
                          rtncmd = cmd.ExecuteNonQuery();
                      }
                      conn.Close();
                  }
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
              return rtncmd;
          }
  </code></pre>