Advertisement

08.01.2008 at 06:02AM PDT, ID: 23613974
[x]
Attachment Details

I am getting the following error, "ODBC Error Code = 37000 (Syntax error or access violation)"

Asked by usky1 in ColdFusion Application Server

This is the full error,
ODBC Error Code = 37000 (Syntax error or access violation)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='.
SQL = "select * from ib_C where ID ="
Data Source = "#dssource#"
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (117:5) to (117:53).


This is the code,


<!---- loop through the URL and collect up IDs into one variable as a list 1,2,3... ----->
<cfset IDs = "">

<cfloop index="ik" from="1" to="3">
  <cfif isDefined("url.ID"&ik)> <!--- does it exist and have a value > 0 ? ---->
    <cfset IDs = listAppend(IDs,url['ID'&ik])> <!--- append to the list ---->
  </cfif>
</cfloop>
 
<cfquery name="getSub" datasource="#dssource#">
 SELECT cnum, IID, sf1, sl1, ID
 FROM ib_c
  where ib_c.cnum = <cfqueryparam value="#URL.cno#" cfsqltype="cf_sql_integer">
 <cfif len(IDs)>
  and ib_c.IID in (<cfqueryparam cfsqltype="cf_sql_varchar" list="Yes" value="#IDs#">)
 <cfelse> <!--- no ids found, so return nothing ---->
  and 1=2
 </cfif>
 ORDER BY IID
</cfquery>



<!---- create a list of IDs fetched from the database into one variable ----->
<cfset databaseIDs = valueList(getSchool.IID)>
<!--- <cfoutput>The IDs from the database: #databaseIDs#</cfoutput><br> --->
<cfset listNotFound = "" />
<!--- loop through IDs from the URL and see if they were fetched from the database ----->
<cfloop index="theIID" list="#IDs#">
  <cfif listFindNoCase(databaseIDs,theIID) eq 0> <!---- is ID found in the database? ----->
        <cfset listNotFound = listAppend(listNotFound, theIID) />
   <!--- ID #theIID# is not in the database.<br> --->
  </cfif>
</cfloop>
<!--- group all id's for cookie --->
<cfset IDs = "">
<cfloop index="i" from="1" to="3">
      <cfif IsDefined("url.id"&i)>
            <cfset intID = Evaluate("url.id"&i)>
            <cfset intID = REReplace(intID, "[^0-9]", "", "all")>
            <cfif intID NEQ "">
                  <cfif getSchool.recordcount GT 0>
                  <cfquery name="GetChild" datasource="#dssource#">
                        select * from ib_c where ID = #intID#
                  </cfquery>
                  <cfelse>
                  </cfif>
                  <cfif getSchool.recordcount GT 0>
                  <cfloop query="GetChild">
                        <cfcookie name="cnum" value="#GetChild.cnum#">
                        <cfset IDs = ListAppend(IDs, intID)>
                  </cfloop>
                  <cfelse>
                  <cfset IDs = ListAppend(IDs, intID)>
                  </cfif>
            </cfif>
      </cfif>
</cfloop>

<!--- group all sn's --->
<cfset SNs = "">
<cfloop index="i" from="1" to="3">
      <cfif IsDefined("url.sn"&i)>
            <cfset intSN = Evaluate("url.sn"&i)>
            <cfif intSN NEQ "">
                  <cfif getSchool.recordcount GT 0>
                        <cfquery name="GetChildSN" datasource="#dssource#">
This is where the error is --->            select * from ib_c where ID = #intID#
                        </cfquery>
                  <cfelse>
                  </cfif>
                  <cfif getSchool.recordcount GT 0>
                  <cfloop query="GetChildSN">
                        <cfset SNs = ListAppend(SNs, intSN)>
                  </cfloop>
                  <cfelse>
                        <cfset SNs = ListAppend(SNs, intSN)>
                  </cfif>
            </cfif>
      </cfif>
</cfloop>

<cfset myarray=ListToArray(#listNotFound#, ",")>
<cfset myList = ArrayToList(myArray, ",")>
<!--- output the array as a list --->

<cfset myarray=ListToArray(#CGI.QUERY_STRING#, "&")>
<cfloop index="ax" from="1" to="#ArrayLen(myarray)#">
      <!--- <cfoutput>#myarray[ax]#</cfoutput> --->
    <cfset variable=#ListToArray(#myarray[ax]#,"=")#>
</cfloop>

<cfset cnum = url.cno>
<cfset fn1 = left(sn1,1)>
<cfset ln1  = mid(sn1,2,len(sn1))>
<cfset fn2 = left(sn2,1)>
<cfset ln2  = mid(sn2,2,len(sn2))>
<cfset fn3 = left(sn3,1)>
<cfset ln3  = mid(sn3,2,len(sn3))>

<cfif listFindNoCase(databaseIDs,id1) eq 0>
      <cfset intID = REReplace(id1, "[^0-9]", "", "all")>
      <cfif IsDefined("#id1#") AND id1 EQ GetChild.IID>
      <cfelse>
      <cfquery name="AddStudent1" datasource="#dssource#">
            INSERT INTO ib_c (cnum, ID, IID, parent_email,
            parent_first, parent_last, sf1, student_grade1, sl1, reason)
            VALUES ('#cnum#', '#intID#', '#id1#','email','pfirst', 'plast','#fn1#', '0', '#ln1#','')
      </cfquery>
      </cfif>
<cfelse>
</cfif>
<cfif listFindNoCase(databaseIDs,id2) eq 0>
      <cfset intID = REReplace(id2, "[^0-9]", "", "all")>
      <cfif IsDefined("#id2#") AND id2 EQ GetChild.IID>
      <cfelse>
      <cfquery name="AddStudent2" datasource="#dssource#">
            INSERT INTO ib_c (cnum, ID, IID, parent_email,
            parent_first, parent_last, sf1, student_grade1, sl1, reason)
            VALUES ('#cnum#', '#intID#', '#id2#','email','pfirst', 'plast','#fn2#', '0', '#ln2#','')
      </cfquery>
      </cfif>
<cfelse>
</cfif><cfif listFindNoCase(databaseIDs,id3) eq 0>
      <cfset intID = REReplace(id3, "[^0-9]", "", "all")>
      <cfif IsDefined("#id3#") AND id3 EQ GetChild.IID>
      <cfelse>
      <cfquery name="AddStudent3" datasource="#dssource#">
            INSERT INTO ib_c (cnum, ID, IID, parent_email,
            parent_first, parent_last, sf1, student_grade1, sl1, reason)
            VALUES ('#cnum#', '#intID#', '#id3#','email','pfirst', 'plast','#fn3#', '0', '#ln3#','')
      </cfquery>
      </cfif>
<cfelse>
</cfif>
Start Free Trial
 
Loading Advertisement...
 
[+][-]08.01.2008 at 08:00AM PDT, ID: 22138909

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: ColdFusion Application Server
Sign Up Now!
Solution Provided By: SidFishes
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628