Integrity constraint violation

When I test this page on my local machine, it works fine. After uploading (including the database) - I get the following error after trying to insert a new record:

-----------error message--------------
ODBC Error Code = 23000 (Integrity constraint violation)

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'AddonID', table 'eldb.dbo.OrderAddons'; column does not allow nulls. INSERT fails.
-----------/error message--------------

I have the AddonID specified in a dropdown menu so it should not be passing a NULL value (and it doesn't on my local machine).

The only difference between my local machine & hosting company is that I'm using Coldfusion MX and they are using Coldfusion 4.5

Also, here is the code for the dropdown menu:

<cfquery name="Addons" datasource="eldb">
SELECT * FROM dbo.AvailableAddons
left join OrderAddons on OrderAddons.AddonID = AvailableAddons.AddonID
</cfquery>
-------------------
<select name="AddonID" class="formareasinput">
         <cfoutput query="Addons">
          <option value="#Addons.AddonID#">#Addons.AddonName#</option>
         </cfoutput>
        </select>


Any ideas?


tatortotAsked:
Who is Participating?
 
JimV_ATLConnect With a Mentor Commented:
Would it be possible to see the insert sql statement on the form that processes the page?

Are you sure that you want to use a left join in your select statement?  The above statement will return null results for the fields in OrderAddons should the AddonID not exist in that table.  It would seem to me that an inner join is appropriate as you would not want a result where the id does not exist in both tables.

Good luck.

Jim

0
 
tatortotAuthor Commented:
Thank you, Jim!!

It was the "inner join" part that was messing things up. All I needed to do was change it to:

----
SELECT *
FROM AvailableAddons
---

Simple as that!

0
All Courses

From novice to tech pro — start learning today.