MDAC 2.5 SDK - ODBC Samples


 

How to Run Admin Demo

You can run the Admin Demo sample by double-clicking the Admndemo.exe file in Microsoft Windows Explorer or by clicking Start, and then Run, and typing \<path>\Admndemo.exe.

Admin Demo Command-Line Switches

Admin Demo supports command-line switches to automatically connect to data sources, execute SQL scripts, and trace ODBC function calls. The switches are:

/D[connection-string]

This switch specifies a connection string for SQLDriverConnect. See the driver documentation for the precise syntax of this string. For example:

 /D[DSN=myserver;UID=Smith;PWD=Sesame;]

Note   Except for the /T option, the /D option must be specified for any other option to work.

/Ffilename

This switch specifies the full path of a file to execute in the same manner used for the File/Execute menu item.

/O:option

This switch specifies a set of options that determine how the file specified with /F is executed. Each option is separated by a colon.

/Tfilename

This switch specifies the full path of a file to use for tracing of ODBC statements made by Admin Demo. This file name is used as a parameter to the SQLSetConnectAttr function with the SQL_ATTR_TRACEFILE option.

/Xoption

Set this switch to 'Y' to force Admin Demo to exit once all other switches have been processed; set it to 'N' (the default) to leave Admin Demo running.

Examples

In the following example, the statement terminator is the semicolon and the maximum statement size is 500:

/O:T';':M500

In the next example, the statement terminator is a carriage return-linefeed character. The maximum statement size is 2500:

/O:TCR:M2500

In the final example, all options are used:

ADMNDEMO.EXE /FC:\SQLADMIN\BACKUP.SQL
   /D[DSN=myserver;UID=Smith;PWD=;]
   /O:TCR:M2000 /TC:\TMP\ADMNDEMO.LOG /XN

When Admin Demo is run, ODBC calls are logged to the C:\TMP\Admndemo.log file, and Admin Demo connects to 'myserver' as user 'Smith' with no password. Once connected, the file C:\SQLADMIN\Backup.sql is executed using a carriage return-linefeed character as a statement terminator with a maximum statement size of 2000. After the file has been executed, the application releases control to the user instead of exiting.