Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

CREATE CONNECTION, MODIFY CONNECTION, RENAME CONNECTION, DELETE CONNECTION

These commands let you maintain connections to remote data sources as part of a database.

Usage

CREATE CONNECTION [ ConnectionName | ? ]
     [ DATASOURCE cDataSource
      [ USERID cUserId ] [ PASSWORD cPassWord ]
      [ DATABASE cDatabase ] ]
     | CONNSTRING cConnectionString ]
MODIFY CONNECTION [ ConnectionName | ? ]
DELETE CONNECTION [ ConnectionName ]
RENAME CONNECTION OldName TO NewName

CREATE CONNECTION lets you either create a connection totally in code or start the Connection Designer. If you include a connection name and either the DATASOURCE or CONNSTRING clause, the connection is created and stored without opening the Designer. Including DATASOURCE or CONNSTRING without a name brings up a Save dialog to specify a name. Anything less than that brings up the Connection Designer. Named connections can be used both in views and in establishing SQL pass-through connections. See “Your Server Will Be With You in a Moment” in Section 1 for more information about connections. In VFP 7, if the database has Database Events turned on, the BeforeCreateConnection and AfterCreateConnection events fire.

MODIFY CONNECTION opens the Connection Designer and lets you edit the specified connection. The BeforeModifyConnection and AfterModifyConnection events of the database fire if Database Events are turned on.

DELETE and RENAME CONNECTION are for maintenance of connections in a database. They do what their names say, and fire the BeforeDeleteConnection, AfterDeleteConnection, BeforeRenameConnection, and AfterRenameConnection events if Database Events are turned on.

Example

CREATE CONNECTION MyAccessConnection ;
  DATASOURCE "MS Access 7.0"
MODIFY CONNECTION MyAccessConnection
RENAME CONNECTION MyAccessConnection TO MoreDignifiedConnection
DELETE CONNECTION MoreDignifiedConnection

See Also

AfterCreateConnection, AfterDeleteConnection, AfterModifyConnection, AfterRenameConnection, BeforeCreateConnection, BeforeDeleteConnection, BeforeModifyConnection, BeforeRenameConnection, Create SQL View, DBGetProp(), Display Connections