title: Read output parameter value from stored procedure
body: <p>My application uses a few stored procedures to insert into multiple tables fairly quickly. The PK value for the inserted rows in each table is used to insert into the next table:</p>
  
  <p>Basically, my stored procedure looks something like this:</p>
  
  <pre><code>create procedure `insert_file`(out @fileid bigint, @filedata longblob, @datesaved datetime)
      begin
          insert into file(filedata, datesaved)
          values(@filedata, @datesaved);
  
          set @fileid = last_insert_id();
      end $$
  delimiter ;
  </code></pre>
  
  <p>What I'm expecting is for this to output the ID for the row that was just inserted so that I can use it in my "joining" table (table that joins this file to another object - like a user or an article).</p>
  
  <p>Here's my code to read this:</p>
  
  <pre><code>Int64 lastInsertID;
  
  // db.getReader(string cmd, List&lt;MySqlParameter&gt;());
  using (MySqlDataReader dr = db.getReader("insert_file", requiredParameters))
  {
      if (dr.HasRows())
      {
          dr.Read();
  
          lastInsertID = dr.GetInt64("@fileid");
      }
  }
  </code></pre>
  
  <p>While this seems to make sense in my head, I keep getting an error:</p>
  
  <blockquote>
    <p>Could not find specified column in results: @fileid</p>
  </blockquote>
  
  <p>Can someone help me understand what I'm doing wrong here (and how to fix it)?</p>