CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • 80040e14 There are fewer columns in the INSERT statement than values specified in the VALUES clause.

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    6267
  • Date Created
    Wednesday, May 3, 2023
  • This Article Has been Viewed
    739 times
  • Short Desc
    While editing sql statements, mistakes are easily made, an in this case, we missed a parameter that needed to be removed with its corresponding variable.
  • Details
    When writing and editing your SQL Statements, you may inadvertently add or remove a parameter causing the following error.

     

    Microsoft OLE DB Driver for SQL Server error '80040e14'

    There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

    /Inserts.asp, line 46
  • Recreate Issue
    The following code will reproduce the error, and it is clear to see what is causing it.

    <%
    Set InsertStart = CreateObject("ADODB.Command")
    InsertStart.ActiveConnection=siteConn
    InsertStart.Prepared = true
    InsertStart.commandtext = "insert into ATime (ID, StartDate)values(?,?,?)"
    InsertStart.Parameters.Append InsertStart.CreateParameter("@ID", adInteger, adParamInput, , strID)
    InsertStart.Parameters.Append InsertStart.CreateParameter("@StartDate", adVarChar, adParamInput, 5, getTenure)
    InsertStart.execute
    %>
  • Resolve Issue
    In this example, it is an easy fix. Remove or add a parameter, and in this case, we are going to remove one of the Question Marks.

    <%
    Set InsertStart = CreateObject("ADODB.Command")
    InsertStart.ActiveConnection=siteConn
    InsertStart.Prepared = true
    InsertStart.commandtext = "insert into ATime (ID, StartDate)values(?,?)"
    InsertStart.Parameters.Append InsertStart.CreateParameter("@ID", adInteger, adParamInput, , strID)
    InsertStart.Parameters.Append InsertStart.CreateParameter("@StartDate", adVarChar, adParamInput, 5, getTenure)
    InsertStart.execute
    %>