title: C# INSERT into an Access DB Memo type field is truncated when using OLEDB 12.0
body: <p>This has been frustrating me and I have yet to find a working answer or solution. There have been a lot of posts and replies, but none that actually explain a working solution.</p>
  
  <p>The Access vulnerableconfiguration  table consists of:</p>
  
  <pre><code>Field Name        Data Type
  cveid             Test
  logicaltest       Memo
  </code></pre>
  
  <p>The relevant code bits where a completely empty vulnerableconfiguration table is populated with completely unique data:</p>
  
  <pre><code>mycon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + accessDb + ";Persist Security Info=False");
  mycon.Open();
  
  ...
  
  insertCommand = new OleDbCommand("INSERT INTO vulnerableconfiguration (cveid, logicaltest) VALUES (@cveid, @logicaltest);", mycon);
  insertCommand.Parameters.Add("@cveid", OleDbType.Char).Value = cve_id);
  insertCommand.Parameters.Add("@logicaltest", OleDbType.LongWChar).Value = vulnerable_configuration);
  insertCommand.ExecuteNonQuery();
  </code></pre>
  
  <p>The logicaltest field values are truncated and I have no clue why. Even the 1st record is truncated from 780 characters to 370! All the memo fields should fit into the memo size limitation. There's no error. I've debugged it and the value set in the insertCommand Parameters has the full value, but when the command is executed, the Access DB has a truncated value.</p>
  
  <p>If anyone has any ideas, it would be great for everyone who's had this issue. </p>
  
  <p>Please don't refer me to <a href="http://allenbrowne.com/ser-63.html" rel="nofollow">http://allenbrowne.com/ser-63.html</a>, none of those cases deal with this straight forward Access insert case. Also, Access 2007/2010 does not have a max length setting for a Memo data type, and it's supposed to grow.</p>
  
  <p>Why am I using Access? This is for an import tool for an Access DB, which is used for look up purposes. Someone else can write some simple queries and reports to get the info they want from it. Not being used as a back-end, and MSSQL is too heavy for this purpose.</p>
  
  <p>Thank you!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Switched to OleDbType.LongWChar for the memo field parameter but I'm still getting the same truncation once the Access record is populated.</p>