Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programatically add a table to a dbc
Message
From
06/01/1999 12:00:48
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00173144
Message ID:
00173181
Views:
25
>>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform