Insert Error

Getting error when I try to insert data into Access

Page 1 of 1

1 Replies - 1782 Views - Last Post: 29 July 2008 - 10:46 AM Rate Topic: -----

#1 abdlah  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-July 08

Insert Error

Posted 29 July 2008 - 10:03 AM

I have an access database with all the fields but PRICE (which is defined as currency) as text and when I submit the values from my form I receive an error: Here is the code:

<!---code to complete date entry --->
 <cfquery datasource="#request.datasource#">
   Insert into Consumer_Product(Cnsmr_ProductID, 
								Cnsmr_ProductNAME, 
								Cnsmr_ProductCATEGORY, 
								Cnsmr_ProductDESCRIPTION, 
								Cnsmr_ProductIMAGE, 
								Cnsmr_ProductPRICE, 
								Cnsmr_ProductModelNO,
								Cnsmr_ProductMODELYEAR,
								User_id)
   Values('#(Form.Cnsmr_ProductID)#',
		  '#(Form.Cnsmr_ProductNAME)#',
		  '#(Form.Cnsmr_ProductCATEGORY)#',
		  '#(Form.Cnsmr_ProductDESCRIPTION)#',
		  '#CFFILE.ServerFile#',
		   #(Form.Cnsmr_ProductPRICE)#,
		  '#(Form.Cnsmr_ProductModelNO)#',
		  '#(Form.Cnsmr_ProductMODELYEAR)#',
		  '#SESSION.auth.User_id#'
 </cfquery>	 



And here is the ERROR:

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

The error occurred in C:\CFusionMX7\wwwroot\e-Ghana\process_consumerProductRegistration.cfm: line 70

68 : '#(Form.Cnsmr_ProductModelNO)#',
69 : '#(Form.Cnsmr_ProductMODELYEAR)#',
70 : '#SESSION.auth.User_id#'
71 : </cfquery>
72 :

SQL Insert into Consumer_Product(Cnsmr_ProductID, Cnsmr_ProductNAME, Cnsmr_ProductCATEGORY, Cnsmr_ProductDESCRIPTION, Cnsmr_ProductIMAGE, Cnsmr_ProductPRICE, Cnsmr_ProductModelNO, Cnsmr_ProductMODELYEAR, User_id) Values('auto3', 'Lexus SUV', 'Cars', 'Lexus SUV, blue black color with only 10000 km', 'p05_astrolabe2.jpg', 35000.00, 'R 330', '2006', 'zuori'
DATASOURCE eghanadb
VENDORERRORCODE -3502
SQLSTATE 42000
Resources:

* 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 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Remote Address 127.0.0.1
Referrer http://localhost:850...egistration.cfm
Date/Time 29-Jul-08 04:45 PM
Stack Trace
at cfprocess_consumerProductRegistration2ecfm1359831049.runPage(C:\CFusionMX7\wwwroot\e-Ghana\process_consumerProductRegistration.cfm:70) at cfprocess_consumerProductRegistration2ecfm1359831049.runPage(C:\CFusionMX7\wwwroot\e-Ghana\process_consumerProductRegistration.cfm:70)

java.sql.SQLException: [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
at macromedia.sequelink.ssp.Diagnostic.toSQLException(Unknown Source)
at macromedia.sequelink.ssp.Chain.cnvDiagnostics(Unknown Source)
at macromedia.sequelink.ssp.Chain.decodeDiagnostic(Unknown Source)
at macromedia.sequelink.ssp.Chain.decodeBody(Unknown Source)
at macromedia.sequelink.ssp.Chain.decode(Unknown Source)
at macromedia.sequelink.ssp.Chain.send(Unknown Source)
at macromedia.sequelink.ctxt.stmt.StatementContext.execDirect(Unknown Source)
at macromedia.jdbc.sequelink.SequeLinkImplStatement.execute(Unknown Source)
at macromedia.jdbc.slbase.BaseStatement.commonExecute(Unknown Source)
at macromedia.jdbc.slbase.BaseStatement.executeInternal(Unknown Source)
at macromedia.jdbc.slbase.BaseStatement.execute(Unknown Source)
at coldfusion.server.j2ee.sql.JRunStatement.execute(JRunStatement.java:212)
at coldfusion.sql.Executive.executeQuery(Executive.java:753)
at coldfusion.sql.Executive.executeQuery(Executive.java:675)
at coldfusion.sql.Executive.executeQuery(Executive.java:636)
at coldfusion.sql.SqlImpl.execute(SqlImpl.java:236)
at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:500)
at cfprocess_consumerProductRegistration2ecfm1359831049.runPage(C:\CFusionMX7\wwwroot\e-Ghana\process_consumerProductRegistration.cfm:70)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:219)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
at coldfusion.CfmServlet.service(CfmServlet.java:107)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

What am I doing wrong.

Is This A Good Question/Topic? 0
  • +

Replies To: Insert Error

#2 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Insert Error

Posted 29 July 2008 - 10:46 AM

One problem is that you are missing a closing parenthesis at the end of your VALUES clause

INSERT INTO TableName ( .... )
VALUES ( ..... )

I do not know if it will cause an error, but you do not need parenthesis around the form field variables:

'#(Form.Cnsmr_ProductID)#'

Lastly, you should consider using cfqueryparam for all query parameters.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1