Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create table syntax
Message
From
29/06/2000 22:44:29
 
 
To
29/06/2000 21:37:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00386897
Message ID:
00386915
Views:
16
>I wrote a code that will create a table (whatever its filename is) to my directory "DATA\". The value of my textbox is "mytable.dbf":
>
>cFileName = CURDIR()+"DATA\"+ALLTRIM(Thisform.txtFileName.Value)
>CREATE TABLE &cFileName (Field1 N(2), Field2 C(8))
>
>- OR -
>
>cFileName = CURDIR()+"DATA\"+ALLTRIM(Thisform.txtFileName.Value)
>CREATE TABLE (cFileName) (Field1 N(2), Field2 C(8))
>
>returns an error message "Field name is a duplicate or invalid."
>
>What could possibly be wrong?

The 2nd statement works fine as long as the directory (CURDIR()+'DATA') exists and the content of the file name value is correct, so I'd start there. When specifying an N field, it's customary to specify two values within parens - the length of the field and the number of places to the right of the decimal place. The following code works fine on my system:
IF ADIR(aFiles,CURDIR()+'DATA','D') = 0
   MKDIR (CURDIR()+'DATA')
ENDIF
cFileName = CURDIR() + 'DATA\'+SYS(2015) +'.DBF'
CREATE TABLE (cFileName) (Field1 N(2), Field2 C(8))
Caveat - SYS(2015) returns a name 10 characters in length; if you have a file system that does not support long file names (eg a Novell NetWare 3.x network without the OS2 NameSpace support loaded) this could fail. If you do not have File Create privileges in the CURDIR() or CURDIR()+'DATA' folder, it can fail. If the hard drive is full it can fail. If the directory is marked as read-only or System it can fail. IOW, the CREATE TABLE statement itself is OK, but something in the construction of the file name may make it invalid, or insufficient privileges.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform