Roger,
I have always just created new databases manually, but I have to do one to copy to a csv, so the field names are not relevant. It is a special export for invoices with wayyyyyyyyyyyy too many fields.
Anyway, I want to create a database and use an array to assign the fields (ie, data001-datea110) all the same field length, c30.
I tried to use your examples but it just give an error, even for one field (testing it). No ch files are missing, if they are necessary.
Tried on like this, but all give an error
aStru := { ;
{ 'DESC', 'C', 50, 0 }, ;
{ 'INTERPRET', 'C', 5000, 0 } }
dbCreate( cPath + 'DCSCRIPT.DBF', aStru, 'DBFNTX' )
Does not like the array set up. I must be missing something. I would rather create a loop on an array. to create the fields
'DATA'+strzero(n,3) where n is the next field up to 110. But I cannot get by the array structure(?)
Any suggestions is appreciated.
Thanks
Fred
Omni
Create Database
Re: Create Database
Fred,
This code works for you?
This code works for you?
Code: Select all
//----------------------------------------------
Proc Main()
LOCAL aStru := {}, MyFolder := 'D:\Data', MyFile:= 'MyDbf.dbf', cDbe := 'DBFNTX'
IF ! File( MyFolder, 'D' )
CreateDir( MyFolder )
Endif
For x:=1 to 110
aadd( aStru, {'MyField'+StrZero(x,3),'C',50,0} )
Next
DbCreate( MyFolder + '\' + MyFile, aStru, cDbe )
If File( MyFolder + '\' + MyFile )
Msgbox('File Create Sucess')
Else
Msgbox('File Create Fail')
Endif
Return
Pedro Alexandre
Re: Create Database
Yes, works. I see what I did not do...old age kicking in.
The 5000 was just a copy issue. The error was the initialization of the array in the beginning. It was somewhere else in his example and I just neglected to do it.
thanks
The 5000 was just a copy issue. The error was the initialization of the array in the beginning. It was somewhere else in his example and I just neglected to do it.
thanks
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: Create Database
Hi, Fred!
Look for "dbCreate" in the text of my system: http://lc.kubagro.ru/__AIDOS-X.txt.
There are different options for creating databases, including what you want to do
Look for "dbCreate" in the text of my system: http://lc.kubagro.ru/__AIDOS-X.txt.
There are different options for creating databases, including what you want to do