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:
  • Microsoft OLE DB Provider for SQL Server (0x80040E14) The name "" is not permitted in this context.

  • 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:
    79
  • Date Created
    Saturday, December 25, 2010
  • This Article Has been Viewed
    1778 times
  • Short Desc
    When passing values to our SQL Statements, we cannot add in the Variables into the statement itself without adding in the appropriate characters that are required. They are thought of as Column Names in this context.
  • Details
    Adding in our Variables into the SQL Statement without the appropriate characters as in:
    "&MyVariable&" (or) ? will give the error below, as it thinks that you are trying to pass a Column Name in place of the Variable value.

     
    Microsoft OLE DB Provider for SQL Server (0x80040E14)
    The name "tdate" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
    /NewInserts.asp, line 415
  • Recreate Issue
    To Recreate this issue.

    <%
    sqlBlList.commandtext="insert into BlackListed (IPAddress, uDate)values(?,tdate)"
    sqlBlList.Parameters.Append sqlBlList.CreateParameter("@IPAddress", advarchar, adParamInput, 50,tempID)

    %>


    As you can see, we are trying to pass the tdate in our value section of our INSERT statement, and this is not allowed.
  • Resolve Issue
    To correct this issue, add the Variable in the right location, and put the ? in your value section of your INSERT code, as shown below.

    <%
    sqlBlList.commandtext="insert into BlackListed (IPAddress, uDate)values(?,?)"
    sqlBlList.Parameters.Append sqlBlList.CreateParameter("@IPAddress", advarchar, adParamInput, 50,tempID)
    sqlBlList.Parameters.Append sqlBlList.CreateParameter("@uDate", advarchar, adParamInput, 30,tdate)

    %>


    In the above, we are passing all our values in our Parameters.