Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking to see in fields exist in database - dbgetprop
Message
 
 
To
11/05/1998 15:31:03
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00098558
Message ID:
00098573
Views:
27
Sheena,

An ON ERROR handler should be able to trap the 1231 error that occurs when you ask for a table.field that doesn't exist.

Or you can use ADBOBJECTS( laTables, "table" ) to get a list of tables in the database, use each one in a loop and do a AFIELDS( laFields ) to find the list of fields.

Note you can't really test the length of the defaultvalue because that can easily be 0 for character fields that indeed do exist in the table.

>I'm writing a utility program to check and see if fields exist in a database and if not, to add them to the database. I also am adding new fields to the database.
>
>I'm using the dbgetprop function to check for fields and if they don't exist I'm using the Alter Table command as follows:
>
>cresults = dbgetprop("client.name", "Field", "defaultvalue")
> = messagebox(cresults)
> If Len(alltrim(cresults)) = 0
>
> Alter Table client ADD column name c(20) default "Murphy"
> Endif
>
>This isn't working. Is there some other way I can check programatically for the existence in a database for fields and their
>type and default values.
>
>Any assistance would be greatly appreciated. Thank you
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform