Skip to main content

Posts

Showing posts from April, 2009

SQL: Does a Field Exist?

In the FoxPro world, checking to see if a field exists can be done a number of ways:

=AFIELDS(la)
IF ASCAN(la,"FIELDNAME")>0

ENDIF

or

IF TYPE("FIELDNAME") = "U"

(I'm sure there are lots of other ways especially if you're already working with a data dictionary tool)

In T-SQL, there is no real equivalent however, you can do the same by using the INFORMATION_SCHEMA table.

While there is no shortage of sites on the web that will show you similar code (like this one), I wanted to post it here for any VFP devs who may be switching between DBFs and SQL.

IF NOT EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = 'MyTable'
AND COLUMN_NAME='MyColumn')
ALTER TABLE myTable ADD MyColumn decimal(10,2) NULL

Of course, this assumes that the table already exists but you can use similar approaches for tables as well.

IF NOT EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'myT…

VFPx Showcase: Control Renamer

When speaking about VFPx at last year's Southwest Fox conference, it became evident that there aren't a lot of avenues for finding out how to use various pieces of VFPx. So as part of the FoxShow, I'm creating videos designed to showcase VFPx components, starting with the Control Renamer.

If you have ever wanted to rename a control in a class or form but were hesitant because of missing other code references, the Control Renamer is definitely a tool you want to try.

Now, there are lots of areas where new options can be added into this tool - but they are primarily "extras" like setting color settings or some logging.

Check it out below!









New VFP 9 SP2 Hotfixes: Report Designer Bug Fixed

Rick Schummer just noted this on his blog but it bears repeating.

A bug that Cathy Pountney had reported with the VFP 9 SP2 Report Designer has been fixed and is available for download, combined with 2 other hotfixes.

As Rick points out:
"Hopefully this is just the third in a string of hotfixes we will see from Microsoft as they support the product we all love. Today is a very good day. This is one small step for VFP, one giant leap for VFP developers. "

Download it here