Forum Moderators: open

Message Too Old, No Replies

"Date" as a field name in Access

an oddity

         

txbakers

6:43 pm on Jul 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I installed an ASP calendar on my site which was written in VBSCRIPT. The db it came with used "Date" as a field name. The calendar worked fine.

I needed to rewrite the code into JavaScript to integrate it into the rest of my site, and although the JS code can read from the table with the name "Date" it can't write to it,causing a syntax error. If I rename the field to "eDate" it works just fine.

I thought it was odd that it would work in VBSCRIPT but not in JS.

I did notice that the VB code didn't use a SQL statement while the JS code did. Would that be the difference?

tomasz

1:12 am on Jul 18, 2002 (gmt 0)

10+ Year Member



That only one thing I can say, is not to good thing to use restricted words like date, field, time etc...

I think VB understands SQL syntax as a field, but still it is not good programming practice to use those words

jatar_k

2:00 am on Jul 18, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



agreed, smacks of a reserved word problem across languages.

txbakers

2:24 am on Jul 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, renaming the field fixed everything, JS and VB, but I thought it odd that it would work in VBSCRIPT at all.

jatar_k

2:29 am on Jul 18, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



me too but, as tomasz said, it isn't good to use restricted words. Oh well maybe the folk that made the calendar read this forum. ;)

Xoc

2:52 am on Jul 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In Access, you can surround field names with square brackets in your SQL. Such as [date] or [field name]. Required for fields with spaces in the name.