Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,189 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,274 people online right now. Registration is fast and FREE... Join Now!




Insert Error

 
Reply to this topicStart new topic

Insert Error, Getting error when I try to insert data into Access

abdlah
post 29 Jul, 2008 - 09:03 AM
Post #1


New D.I.C Head

*
Joined: 21 Jul, 2008
Posts: 4

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
<!---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:8500/e-ghana/consumerProd...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.
User is offlineProfile CardPM

Go to the top of the page

sansclue
post 29 Jul, 2008 - 09:46 AM
Post #2


D.I.C Head

**
Joined: 21 Nov, 2007
Posts: 105



Thanked 7 times
My Contributions


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.




User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 04:31PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month