Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programatically add a table to a dbc
Message
De
06/01/1999 12:00:48
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00173144
Message ID:
00173181
Vues:
26
>>>>How do I programatically add a table to a dbc?
>>>
>>>Hi Albert,
>>>
>>>Look at the ADD TABLE command in the help file.
>>
>>Thanks, thought I looked for that... oh well.
>>
>>Incidentally, the help file says that you can use the array created by afields() for a create table XXXX from array aaaa. This does not work. It says that the table already exists. The name of the table used to generate the array is stored in array[1,12]. If that array element is replaced with the new table name, create table works. This would imply that the table name is not necessary for the create table command, but this generates a syntax error.
>
>Hi Albert,
>
>This does and doesn't work. It does work with a free table. It doesn't with a table connected with a DBC.

Explain? I VFP6.0 the table is appearing in the dbc. The following code works:
***********************************************************
* function:
*	MakeTempTable
*
* parameters:
*	tcTarget - table to be updated (character)
*
* abstract:
*	Create a temporary table with the same structure as
*	tcTarget and return the temporary table's name.
***********************************************************

function MakeTempTable ( tcTarget )
set step on
	do case

		* two parameters are required
		case pcount() < 1
			return TOOFEWPARMS

		case vartype(tcTarget) != 'C' or empty(tcTarget)
			return NOTARGETPARM

	endcase

	* make consistent
	tcTarget = upper(alltrim(tcTarget))
	
	local array laDBObjects[1]
	local lnDBObjectCount
	
	lnDBObjectCount = adbobjects( laDBObjects, "TABLE" )
	
	if ascan( laDBObjects, tcTarget ) = 0
		return NOTARGETTABLE
	endif
		
	select 0
	use ( tcTarget ) again alias TargetTable

	local array laFields[1]
	local lnFieldCount, lcTableName
	
	lnFieldCount = afields( laFields )
	lcTableName = sys( 2015 )	&& generate unique name	
	laFields[1, 12] = lcTableName
	use
	
	create table ( lcTableName ) from array laFields
	use
	
	return lcTableName
	
endfunc
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform