Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Syntax error in INSERT INTO statement.

Author  Topic 

kathunter
Starting Member

35 Posts

Posted - 2001-04-24 : 17:35:05
This is driving me crazy. I know that text is delimited by apostrophies and dates in access are delimited by # signs, but this is still giving me error messages... The problem is with the date and time fields. Time is an integer with 2 decimal places (ie: 1.75). If I enter the time without decimals, it works, so I tried a replace clause, but that did not work.

The date won't work in any case.

Code below:

'define your variables
Dim employeeID, trDate, companyID, packageID, time, description
employeeID=Request.Form("employeeID")
trDate=Request.Form("date")
companyID=Request.Form("companyID")
packageID=Request.Form("packageID")

'this code is to prevent apostrophy errors, period
description=Request.Form("description")
description=Replace(description,"'","´")
time=Request.Form("time")
' time=Replace(time,".","­")


'insert into the database
Dim SQLaddtr, oRSaddtr
SQLaddtr= ""
SQLaddtr= SQLaddtr + "INSERT INTO timeentries "
SQLaddtr= SQLaddtr + "(employeeID, date, companyID, packageID, time, description) "
SQLaddtr= SQLaddtr + "VALUES (" + employeeID + ", #" + trDate + "#, " + companyID + ", " + packageID + ", " + time + ", '" + description + "');"


set oRSaddtr=objConnection.execute(SQLaddtr)

 


I should have taken the blue pill
   

- Advertisement -