You have accessors="true" on your component right?

On Mon, Jan 11, 2010 at 3:05 PM, Scott Brady <dsbr...@gmail.com> wrote:

>
> I'm using the new "bean" type of component in CF9 for the first time
> and I'm running into a frustrating problem when trying to insert into
> the database (SQL Server 2005). The bean is set up with the following
> code:
>
> <cfcomponent name="myBean.cfc" hint="This sets and gets properties for
> my bean" strict="true">
>        <cfproperty name="myID" type="int" default="0" />
>        <cfproperty name="userID" type="int" default="0" />
>        <cfproperty name="fileName" type="string" default="" />
>        <cfproperty name="rowsInFile" type="int" default="0" />
>        <cfproperty name="rowsAttempted" type="int" default="0" />
>        <cfproperty name="rowsFailed" type="int" default="0" />
>        <cfproperty name="statusID" type="int" default="1" />
>        <cfproperty name="startTime" type="date" />
>        <cfproperty name="endTime" type="date" />
>        <cfproperty name="created" type="date" />
>        <cfproperty name="createdBy" type="int" default="0" />
>        <cfproperty name="modified" type="date" />
>        <cfproperty name="modifiedBy" type="int" default="0" />
>        <cfproperty name="active" type="boolean" default="true" />
> </cfcomponent>
>
> And, in a DAO, I have the following insert:
>                        INSERT INTO myTbl
>                        (
>                                userID,
>                                fileName,
>                                rowsInFile,
>                                rowsAttempted,
>                                rowsFailed,
>                                statusID,
>                                startTime,
>                                endTime,
>                                created,
>                                createdBy,
>                                modified,
>                                modifiedBy,
>                                active
>                        )
>                        VALUES
>                        (
>                                <cfqueryparam
> value="#arguments.bean.getAdvertiserID()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getFileName()#"
> cfsqltype="cf_sql_varchar" />,
>                                <cfqueryparam
> value="#arguments.bean.getRowsInFile()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getRowsAttempted()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getRowsFailed()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getStatusID()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getStartTime()#"
> cfsqltype="cf_sql_datetime" />,
>                                <cfqueryparam
> value="#arguments.bean.getEndTime()#"
> cfsqltype="cf_sql_datetime" null="#NOT
> isDate(arguments.bean.getEndTime())#" />,
>                                <cfqueryparam
> value="#arguments.bean.getCreated()#"
> cfsqltype="cf_sql_datetime" />,
>                                <cfqueryparam
> value="#arguments.bean.getCreatedBy()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getModified()#"
> cfsqltype="cf_sql_datetime" />,
>                                <cfqueryparam
> value="#arguments.bean.getModifiedBy()#"
> cfsqltype="cf_sql_int" />,
>                                <cfqueryparam
> value="#arguments.bean.getActive()#" cfsqltype="cf_sql_bit" />
>                        );
>
>
> (the endTime column can be null, and for the insert, it pretty much
> should be -- the other date fields default to getdate())
>
> When I run the insert, I get this error:
> Conversion failed when converting datetime from character string.
>
> I've tried using the default attribute for the properties to set them
> to #now()# (which didn't seem to actually set the value). When
> instantiating a bean, I've tried setting the non-nullable dates to be
> #now()#.  I've taken my query and put it into SQL Server (hard-coding
> values) and it works.  I've tried using createODBCDateTime() [as in my
> example] in case there was something weird with the way the dates were
> formatted (haven't had to do that in the past).  If I take out all of
> the date fields in the query, it works.  And, it appears to be every
> date field that causes the problem (well, not endTime, since the null
> is working).
>
> So, I'm at a loss.  Short of going back to the "old" way of doing
> beans [manually doing the getters and setters], I don't know what to
> do.
>
> Any suggestions?
>
> Scott
> --
> -----------------------------------------
> Scott Brady
> http://www.scottbrady.net/
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329554
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to