Error executing sql statement

I

Ivan Debono

Hi,

I'm executing the following SQL statement using ado 2.8:

ALTER TABLE mytable ADD myfield text DEFAULT('')

And get the following error:
Microsoft JET Database Engine (3320) Missing ), ], or Item in table-level
validation expression.

I don't see anything missing. What the problem then?

Thanks,
Ivan
 
D

Dave Patrick

Try;

ALTER TABLE mytable ADD myfield text(x)

(where x = the string length)

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Hi,
|
| I'm executing the following SQL statement using ado 2.8:
|
| ALTER TABLE mytable ADD myfield text DEFAULT('')
|
| And get the following error:
| Microsoft JET Database Engine (3320) Missing ), ], or Item in table-level
| validation expression.
|
| I don't see anything missing. What the problem then?
|
| Thanks,
| Ivan
|
|
 
A

Allen Browne

Ivan, if memory serves correctly, JET does not accept DEFAULT in DDL queries
executed under DAO (which is how the Access interface works), but it does
accept it if the DDL is executed under ADO.

Try:
Dim strSql As String
strSql = "ALTER TABLE MyTable ADD COLUMN MyZLSfield TEXT (100) DEFAULT
"""";"
CurrentProject.Connection.Execute strSql


Naturally, this requires the field's Allow Zero Length property is set to
Yes. This property is set inconsistently in different versions of Access and
depending on how the field is created. In general you want this property set
to No, but perhaps you have a special case.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ivan Debono said:
What happens to the default? Doesn't JetSQL support it?

Ivan

Dave Patrick said:
Try;

ALTER TABLE mytable ADD myfield text(x)

(where x = the string length)

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Hi,
|
| I'm executing the following SQL statement using ado 2.8:
|
| ALTER TABLE mytable ADD myfield text DEFAULT('')
|
| And get the following error:
| Microsoft JET Database Engine (3320) Missing ), ], or Item in
table-level
| validation expression.
|
| I don't see anything missing. What the problem then?
|
| Thanks,
| Ivan
 
I

Ivan Debono

Actually it does, but only from Jet 5.0 but the syntax is:
DEFAULT 0 instead of DEFAULT(0)
DEFAULT "hello" instead of DEFAULT('hello')

Ivan

Allen Browne said:
Ivan, if memory serves correctly, JET does not accept DEFAULT in DDL
queries executed under DAO (which is how the Access interface works), but
it does accept it if the DDL is executed under ADO.

Try:
Dim strSql As String
strSql = "ALTER TABLE MyTable ADD COLUMN MyZLSfield TEXT (100) DEFAULT
"""";"
CurrentProject.Connection.Execute strSql


Naturally, this requires the field's Allow Zero Length property is set to
Yes. This property is set inconsistently in different versions of Access
and depending on how the field is created. In general you want this
property set to No, but perhaps you have a special case.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Ivan Debono said:
What happens to the default? Doesn't JetSQL support it?

Ivan

Dave Patrick said:
Try;

ALTER TABLE mytable ADD myfield text(x)

(where x = the string length)

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Hi,
|
| I'm executing the following SQL statement using ado 2.8:
|
| ALTER TABLE mytable ADD myfield text DEFAULT('')
|
| And get the following error:
| Microsoft JET Database Engine (3320) Missing ), ], or Item in
table-level
| validation expression.
|
| I don't see anything missing. What the problem then?
|
| Thanks,
| Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top