bb.donnay-software.com

Donnay Software Web Forums
It is currently Sat Feb 22, 2020 4:07 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Create Database
PostPosted: Fri Feb 14, 2020 7:22 am 
Offline

Joined: Thu Jan 28, 2010 9:34 am
Posts: 470
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


Top
 Profile  
 
 Post subject: Re: Create Database
PostPosted: Fri Feb 14, 2020 8:00 am 
Offline
User avatar

Joined: Tue Feb 09, 2010 3:06 am
Posts: 130
Fred,

This code works for you?

Code:
//----------------------------------------------
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


Top
 Profile  
 
 Post subject: Re: Create Database
PostPosted: Fri Feb 14, 2020 8:33 am 
Offline

Joined: Mon Feb 01, 2010 8:45 am
Posts: 121
Fred,
a char field with 5000 characters ?

_________________
Klaus


Top
 Profile  
 
 Post subject: Re: Create Database
PostPosted: Fri Feb 14, 2020 8:36 am 
Offline

Joined: Thu Jan 28, 2010 9:34 am
Posts: 470
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


Top
 Profile  
 
 Post subject: Re: Create Database
PostPosted: Sat Feb 15, 2020 10:15 pm 
Offline
User avatar

Joined: Sat Feb 04, 2012 2:23 am
Posts: 1323
Location: Russia, Southern federal district, city of Krasnodar
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

_________________
http://sj.kubsau.ru/editorialboard
http://sj.kubsau.ru/authors/521
http://translate.google.ru/translate?hl ... ubagro.ru/
http://lc.kubagro.ru/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group