﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WebForms (How do I?)  » excel help give  OleDbException Syntax error in INSERT INTO statement</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 07:02:20 GMT</lastBuildDate><ttl>20</ttl><item><title>excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27119.aspx</link><description>Bonjour when I try to export using the excel helper I recieved this error message&lt;/P&gt;&lt;P&gt;OleDbException&lt;BR&gt;&amp;nbsp; Syntax error in INSERT INTO statement.&lt;/P&gt;&lt;P&gt;Source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Microsoft JET Database Engine&lt;/P&gt;&lt;P&gt;NB. the excel file is created but with only the header &lt;/P&gt;&lt;P&gt;Thank you</description><pubDate>Fri, 14 May 2010 17:01:25 GMT</pubDate><dc:creator>Jocelyn Dagrain</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27148.aspx</link><description>Bonjour after investigation I found this list of error and possible solutions:&lt;/P&gt;&lt;P&gt;- The error message (Syntax error in INSERT INTO statement&amp;nbsp; Microsoft JET Database Engine) was cause by a null value in my table.&lt;/P&gt;&lt;P&gt;Solution:&amp;nbsp; I make sure there is no null value in the table&lt;/P&gt;&lt;P&gt;- The error message (Numeric field overflow&amp;nbsp; Microsoft JET Database Engine) is cause by the default date time value (1800-01-01 00:00:00.000)&lt;/P&gt;&lt;P&gt;Partial Solution: modify the sql statement&amp;nbsp; [convert(varchar(10), Tbl_CreatedDate, 101) as Tbl_CreatedDate]&lt;/P&gt;&lt;P&gt;This eliminate the error but in excel the date is format as string this can be problematic for accounting user who rely on excel built-in function to do their job.&lt;/P&gt;&lt;P&gt;More on this error message:&amp;nbsp; Miscrosoft Article ID: 815277&lt;/P&gt;&lt;P&gt;This article is base on MS Access scenario but I think it might apply&lt;/P&gt;&lt;P&gt;Link: &lt;A href="http://support.microsoft.com/kb/815277"&gt;http://support.microsoft.com/kb/815277&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Access assigns a data type for each field of the Excel spreadsheet. This assignment is based on the data that is contained in the first eight rows. For example, if a field has a Number data type that is in the first eight rows and then has text values in some of the remaining rows, Access assigns the Number data type to the link table field. This causes Access to fail to link the records that have text data values. When you query this field, Microsoft Jet Database Engine encounters text where a number is expected. The query fails with the error message in the "Symptoms" section.&lt;/P&gt;&lt;P&gt;- On last error message this time manageable by error handling (The process cannot access the file 'C:\Users\dagrainj.AIM\Downloads\tset2.XLS' because it is being used by another process.)&lt;/P&gt;&lt;P&gt;this can occur if the excel file is save in a share directory (other user might cause this error simply by opening the file) &lt;/P&gt;&lt;P&gt;Thank you in advance</description><pubDate>Fri, 14 May 2010 17:01:25 GMT</pubDate><dc:creator>Jocelyn Dagrain</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27147.aspx</link><description>Peering into the code a little more, I recognized something quite interesting.  The only column types handled by the export are int, long, datetime and string.  If there is anything else in that business object outside of those types, then they are considered strings.  You may have to excluded those BLOB-type columns from your export.</description><pubDate>Fri, 14 May 2010 15:06:36 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27145.aspx</link><description>I looked at the ExportToExcel_AddRow method in the source code.  It uses a StringBuilder to put together the syntax involved in the create row method.  It is basically a SQL INSERT INTO command.  The column names are surrounded with brackets, so hopefully, that would take care of that problem; however, there may be an issue with invalid string data within the business object.  Here is the syntax for a string field:&lt;br&gt;
&lt;br&gt;
createRow.Append("'" + bo.CurrentRow[col.ColumnName].ToString().Replace("'","") + "'");&lt;br&gt;
&lt;br&gt;
createRow is the StringBuilder object.  Maybe the Replace method should read: .Replace("'", "''").  Not sure how to solve the problem.  Check your string data in the business object and see if anything stands out.&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 14 May 2010 14:50:02 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27144.aspx</link><description>With a SQL syntax error, my first guess would be that one of you column names is causing an issue.&lt;br&gt;
&lt;br&gt;
If that isn't the problem, then the best way to get to the bottom of this is for you create a small sample app that demonstrates the problem.</description><pubDate>Fri, 14 May 2010 14:32:24 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27139.aspx</link><description>Bonjour&lt;BR&gt;I use this code &lt;/P&gt;&lt;P&gt;&amp;nbsp;//-----Employee Export excel --------------------&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void toolStripButtonExcel_Click(object sender, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //-- Export the BO to an excel document&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (saveFileDialog1.ShowDialog() == DialogResult.OK)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MicroFour.StrataFrame.Tools.ExcelHelper.ExportToExcel(entityBO1, saveFileDialog1.FileName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;-My OS is window 7 in 32bit&lt;BR&gt;-My project is using platform target x86&lt;BR&gt;-My version of Jet engin is:&lt;BR&gt;HKEY_LOCAL_MACHINE, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Software\\Microsoft\\Jet\\4.0\\Engines&lt;BR&gt;within the Engines folder I also have Jet 2.x/Jet 3.x/Jet 4.0&lt;/P&gt;&lt;P&gt;Thsnk you</description><pubDate>Thu, 13 May 2010 23:04:34 GMT</pubDate><dc:creator>Jocelyn Dagrain</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27138.aspx</link><description>Hi Jocelyn,&lt;br&gt;
&lt;br&gt;
Don't know if this is relevant or no, but if you are testing on a 64bit OS it could be possible that the OleDB driver being used is just for 32bit OS, if that is the case you will need to compile your project specifically for x86 instead of "AnyCPU" the default value and test again.</description><pubDate>Thu, 13 May 2010 20:18:35 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27137.aspx</link><description>Hi Jocelyn,&lt;br&gt;
&lt;br&gt;
Thanks for the stack trace!  Would you be able to provide the code on and around HomePage.cs:line 90?  It seems odd to me that the export is running an INSERT INTO statement against your database.  Do you know where the INSERT INTO is coming from?  I have never used the ExportToExcel method in the StrataFrame Tools namespace.  Sounds interesting.&lt;br&gt;
&lt;br&gt;
Bill</description><pubDate>Thu, 13 May 2010 07:30:45 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27135.aspx</link><description>Bonjour here is the full error message thank you&lt;/P&gt;&lt;P&gt;System.Data.OleDb.OleDbException was unhandled by user code&lt;BR&gt;&amp;nbsp; Message="Syntax error in INSERT INTO statement."&lt;BR&gt;&amp;nbsp; Source="Microsoft JET Database Engine"&lt;BR&gt;&amp;nbsp; ErrorCode=-2147217900&lt;BR&gt;&amp;nbsp; StackTrace:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object&amp;amp; executeResult)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp;amp; executeResult)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object&amp;amp; executeResult)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Tools.ExcelHelper.ExportToExcel_AddRows(OleDbConnection connection, BusinessLayer businessObject)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at MicroFour.StrataFrame.Tools.ExcelHelper.ExportToExcel(BusinessLayer businessObject, String outputPathAndFileName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at JDSolutions.Sys.HomePage.toolStripButtonExcel_Click(Object sender, EventArgs e) in C:\Users\dagrainj.AIM\Documents\JDS\JDSolutions\JDSolutions\Sys\HomePage.cs:line 90&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WmMouseUp(Message&amp;amp; m, MouseButtons button, Int32 clicks)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ScrollableControl.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.ToolStrip.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.OnMessage(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Control.ControlNative&amp;#119;indow.WndProc(Message&amp;amp; m)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Windows.Forms.Native&amp;#119;indow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)&lt;BR&gt;&amp;nbsp; InnerException: &lt;BR&gt;</description><pubDate>Wed, 12 May 2010 22:16:54 GMT</pubDate><dc:creator>Jocelyn Dagrain</dc:creator></item><item><title>RE: excel help give  OleDbException Syntax error in INSERT INTO statement</title><link>http://forum.strataframe.net/FindPost27127.aspx</link><description>Could provide some more information? SQL statement example...stack trace....</description><pubDate>Wed, 12 May 2010 13:31:18 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>