Advertisement

08.01.2008 at 06:02AM PDT, ID: 23613974
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

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 30-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...
20081112-EE-VQP-44 / EE_QW_2_20070628