Create Database

This forum is for eXpress++ general support.
Post Reply
Message
Author
omni
Posts: 478
Joined: Thu Jan 28, 2010 9:34 am

Create Database

#1 Post by omni »

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

User avatar
PedroAlex
Posts: 139
Joined: Tue Feb 09, 2010 3:06 am

Re: Create Database

#2 Post by PedroAlex »

Fred,

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

Koverhage
Posts: 123
Joined: Mon Feb 01, 2010 8:45 am

Re: Create Database

#3 Post by Koverhage »

Fred,
a char field with 5000 characters ?
Klaus

omni
Posts: 478
Joined: Thu Jan 28, 2010 9:34 am

Re: Create Database

#4 Post by omni »

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

User avatar
Eugene Lutsenko
Posts: 1351
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Create Database

#5 Post by Eugene Lutsenko »

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

Post Reply