0

Ok... developing a new website using CFWHEELS framework on CF9 & MSSQL 2008 R2

Everything is working fine except that after I insert some data to the DB and request the primary key it return invalid.

At the begging I thought was a CFWHEELS bug so I created my own CFQUERY.

Here is what I have

<cfquery name="qryInsert" datasource="medriseResearch" result="qryUser">
    INSERT INTO tbl_users (userFirstname, userLastname, userAddress, userAddress2, userCity, userState, userZipcode, userCountry, userBirth, userEmail, userCellphone, userHomephone, userRace, userMarital,userGender)
    VALUES ('#Form.TXTFNAME#','#Form.TXTLNAME#','#Form.TXTADDRESS#','#Form.TXTADDRESS2#','#Form.TXTCITY#','#Form.DROPSTATES#','#Form.TXTZIPCODE#','US','#Form.TXTDOB#','#Form.TXTEMAIL#','#Form.TXTCELLPHONE#','#Form.TXTHOMEPHONE#','#Form.DROPRACE#','#Form.DROPMARITAL#','#Form.DROPGENDER#')
</cfquery>
<cfquery name="qryProfile" datasource="medriseResearch">
    INSERT INTO tbl_advanceprofiles (userId,medicalInsurance,medicalCondition,educationLevel,employeeStatus,employeeIncome)
    VALUES (#qryUser.IDENTITYCOL#,'#Form.dropHealthinsurance#','#Form.dropCondition#','#Form.dropEducation#','#Form.dropEmpstatus#','#Form.dropIncome#')
</cfquery>

The first insert works and it saves the data to my DB. But the second INSERT does not work I get an error saying that qryUser.IDENTITYCOL is invalid.

Any idea why this is happening?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Medrise
  • 81
  • 1
  • 1
  • 6
  • Here's a post that seems to be displaying the same behavior. Are you using a native SQL driver? http://www.akbarsait.com/blog/index.cfm/2008/9/14/Using-Result-attribute-in-CFQuery-to-retrieve-AutoGenerated-Key-on-Insert-in-ColdFusion-8 – squillman Feb 23 '12 at 18:35
  • Yes, I'm using the native SQL driver – Medrise Feb 23 '12 at 18:41

1 Answers1

0

Try using the built-in object function valid() to view what errors Wheels returns. I've used this before to discover that my validation rules were failing due to datatype mismatch, truncated text, etc.

http://cfwheels.org/docs/1-1/function/valid