PDA

View Full Version : Convert problem using SQLSERVER


Metalhunter
05-23-2003, 05:42 AM
Hello

I have a problem to insert data in a SQLSERVER database.

I have this error:

The name '#22 is illegal in this context' Only constant, constant expressions, or variables allowed here. Column are illegal

This is my code:
sqlInsComdef = "insert into comdef(defect_nummer, defect_begindatum, defect_begintijd) values (CONVERT(numeric(8,0), '"& defectNummer & "') , #" & date() & "# , #" & time() & "# )"

I placed this response.write sqlInsComdef:response.end to see the output
The outut is: insert into comdef(defect_nummer, defect_begindatum, defect_begintijd) values (CONVERT(numeric(8,0), '00000001') , #22-5-2003# , #22:54:36# )

What is wrong?

Thanks
Metalhunter

sunpost
05-24-2003, 12:18 AM
i think SQL Server uses single quotes for date and time values...

sqlInsComdef = "insert into comdef(defect_nummer, defect_begindatum, defect_begintijd) values (CONVERT(numeric(8,0), '"& defectNummer & "') , '" & date() & "' , '" & time() & "' )"

you might want to use the GETDATE() T-SQL function or set the columns default value to the GETDATE() function.

Metalhunter
05-26-2003, 03:32 AM
It works

Thank you