title: Server Side using C# to access Oracle DB through ODBC datasource failed while C# long datatype mapping to Oracle Number
body: <p>I am writing a WebApi to provide client users to upload files and the file information will saved to Oracle Database through ODBC(32-bit). The WebApi server side language is C#. The filesize datatype in Oracle is Number.
  I get the filesize from "new System.IO.FileInfo(fileSavePath).Length" and its datatype is long. Then I pass it by the following codes:</p>
  
  <pre><code>String strCmd = "INSERT INTO UPLOAD_FILE (FILENAME, FILETYPE, FILESIZE) Values (:Filename, :Filetype, :Filesize)";
  using (OdbcConnection conn = new OdbcConnection(strConn))
  {
    using (OdbcCommand cmd = new OdbcCommand(strCmd, conn))
    {                    
      cmd.Parameters.AddWithValue(":Filename", FILE.FILENAME); //FILE is CLASS.
      cmd.Parameters.AddWithValue(":Filetype", FILE.FILETYPE);
      cmd.Parameters.AddWithValue(":Filesize", FILE.FILESIZE);
      conn.Open();
      cmd.ExecuteNonQuery();
    }
  }
  </code></pre>
  
  <p>And the Insert action fails.
  According the two Datatype mapping tables:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/odbc-data-type-mappings" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/odbc-data-type-mappings</a></p>
  
  <p><a href="https://docs.oracle.com/cd/E15817_01/server.111/e10311/apa.htm" rel="nofollow noreferrer">https://docs.oracle.com/cd/E15817_01/server.111/e10311/apa.htm</a></p>
  
  <p>I thought it should be no problem.
  Even though I changed the codes to:</p>
  
  <pre><code>cmd.Parameters.Add(new OdbcParameter
  {
     ParameterName = ":Filesize",
     OdbcType = OdbcType.BigInt,
     Value = FILE.FILESIZE
  });
  </code></pre>
  
  <p>And set the datatype of the filesize to Number(19,0)...It still faild.</p>
  
  <p>However, if I let the datatype be int or decimal and it works:</p>
  
  <pre><code>Convert.ToInt32(FILE.FILESIZE) / Convert.ToDecimal(FILE.FILESIZE)
  </code></pre>
  
  <p>SO my question is why the SQL_BIGINT(ODBC) or long(C#/.Net) can't map to Oracle Number datatype??? Or I miss some conversion processes???</p>