0 Replies Latest reply on Dec 7, 2006 12:51 PM by palhan

    Saving a file received from client in database


      <!--- Sets the file source --->
      <cfset rfsfile = "#form.accepted_attachedfile1#">
      <cfset rfsid = "#form.rfsid#">

      <!--- Reads The Files Binary Data --->
      <cffile action="readBinary" file="#rfsfile#" variable="MyVariable">

      <cfset MyBLOB = toBase64(#MyVariable#)>

      <!--- Save the file in database --->
      <cfquery datasource="manpower" username="devegov" password="dev@egov" name="insertfile">
      values (<cfqueryparam value="#MyBLOB#" cfsqltype="cf_sql_blob">)
      <cfoutput query="insertfile">
      <cflocation url="/rfs_backend/RFS_detail.cfm">

      The table is :

      create table TBL_RFS_ATTACHEDFILES (
      RFS_BLOBID INT generated by default as identity (increment by 1,start with 1) not null,
      RFS_BLOB BLOB (500000),
      primary key (RFS_BLOBID));

      I am getting the following error in this code.........

      Error casting an object of type to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.

      The error occurred in C:\CFusionMX7\wwwroot\rfs_backend\RFS_SaveRFSDetails.cfm: line 22

      20 : <cfquery datasource="manpower" username="devegov" password="dev@egov" name="insertfile">
      21 : insert into TBL_RFS_ATTACHEDFILES (RFS_BLOB)
      22 : values (<cfqueryparam value="#MyBLOB#" cfsqltype="cf_sql_blob">)
      23 : </cfquery>
      24 : <cfoutput query="insertfile">

      Please try the following:

      * Check the ColdFusion documentation to verify that you are using the correct syntax.
      * Search the Knowledge Base to find a solution to your problem.

      Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0
      Remote Address
      Referrer http://localhost:8500/rfs_backend/RFS_detail.cfm?rfsid=3008
      Date/Time 07-Dec-06 03:48 PM
      Stack Trace
      at cfRFS_SaveRFSDetails2ecfm555042871.runPage(C:\CFusionMX7\wwwroot\rfs_backend\RFS_SaveRFSD etails.cfm:22)

      at coldfusion.sql.InParameter.setStatement(InParameter.java:49)