Use the SCONNECT command to connect R:BASE to a foreign data source.
Options
datasource
Specifies the name of the data source name (DSN) that contains the table to access.
IDENTIFIED BY userid
Specifies the user account name for the data source. You can use '' (two single quotes) in this position if there is no User ID.
password
Specifies the password for the data source. You can use '' (two single quotes) in this position if there is no password.
About the SCONNECT Command
To access an R:BASE database, the R:BASE or Oterro ODBC driver must be installed. The R:BASE/Oterro ODBC driver version must match the version of the database files that are being connected.
Omitting the datasource option will display a dialog box, listing data sources from which to choose, and continues with prompts for a userid and password.
Use the SATTACH command to attach tables to a database. Added data source tables, or SERVER tables, within an R:BASE database will remain defined as part of the database structure, and will appear in the Database Explorer table list. To disconnect a DSN connection, use the same syntax with the SDISCONNECT command.
About the DSN-Less Connection
A data source name (DSN) is a data structure that contains the information about a specific database that an Open Database Connectivity (ODBC) driver needs in order to connect to it. Included in the DSN, which resides either in the registry or as a separate text file, is information such as the name, directory and driver of the database, and, depending on the type of DSN, the ID and password of the user. The developer creates a separate DSN for each database. To connect to a particular database, the developer specifies its DSN within a program. In contrast, DSN-less connections require that all the necessary information be specified within the command. DSN-Less connection requires no server setup, just a carefully constructed connection string.
There are three kinds of DSN: user DSNs (sometimes called machine DSNs); system DSNs; and file DSNs. User and system DSNs are specific to a particular computer, and store DSN information in the registry. A user DSN allows database access for a single user on a single computer, and a system DSN for any user of a particular computer. A file DSN contains the relevant information within a text file with a .DSN file extension, and can be shared by users of different computers who have the same drivers installed.
DSN-less connections demand that you know the name of the file (e.g. file based databases like R:BASE) or the address of the data server (SQL Server for example).
Armed with appropriate information you could open a data source without a DSN. Normally on the SCONNECT command you specify the DSN you want to use. ODBC looks up this DSN and determines the driver to use and what connection it needs. With this method, R:BASE allows the ability to specify the ODBC driver instead of a DSN.
About the Connection String
The first character in the connection string is a semi-colon. This is the flag which states the string is not specifying a DSN.
The value after "driver" is the actual name of the driver as defined in the ODBC Data Source Administrator. Make sure to spell and space the driver name exactly as it is defined in ODBC Administrator interface under the "Drivers" tab.
The database name and exact path is specified in the "dbq" portion of the string.
The entire string must be surrounded by the database QUOTE character. Single quotes are used in the examples below.
Examples
Example 01 (Using R:BASE 11 ODBC Driver):
SCONNECT ';driver=R:BASE 11 Database Driver (*.RX1);dbq=d:\SampleData\RRBYW20'
Example 02 (Using Oterro 11 ODBC Driver):
SCONNECT ';driver=Oterro 11 Database Driver (*.RX1);dbq=d:\SampleData\RRBYW20'
Example 03 (To use an Access database in "dsnless" mode):
Uses a database called db1.mdb in the "My Documents" folder. The connection can specify additional items like user id with the "UID=" parameter and a password with the "PWD=" parameter.
SCONNECT ';Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\Documents and Settings\Administrator\My Documents\db1.mdb;'
Example 04 (To use a SQL Server database):
The server and database are specified along with the uid and pwd.
SCONNECT ';driver={SQL Server};server=corpseadb0d;uid=my_user_name;pwd=my_pw;database=JohnDoe;'