DATABASE: Difference between revisions
m (→DSN) |
|||
Line 47: | Line 47: | ||
Using ODBC Manager as the parameter will allow the end user to select the desired data source. | Using ODBC Manager as the parameter will allow the end user to select the desired data source. | ||
The following is a sample program that will use the ODBC-MANAGER to identify the proper connection string. | |||
* Note: This will not work in Client Server * | |||
00010 PRINT Newpage | |||
00011 IF Env$("br_model")="CLIENT_SERVER" THEN PRINT "Warning, you cannot connect to ODBC-MANAGER in Client Server Mode" | |||
00020 EXECUTE "config database Test_DB ODBC-MANAGER" ERROR CONNECT_ERROR | |||
00030 PRINT "Connection String is:" !: | |||
PRINT Env$("STATUS.DATABASE.[TEST_DB].CONNECTSTRING") | |||
00099 STOP | |||
00100 CONNECT_ERROR: ! | |||
00110 PRINT "Error Connecting - Err:";Err;" Line:";Line;" Syserr:";Syserr$ | |||
[[Category:All Parameters]] | [[Category:All Parameters]] |
Revision as of 20:19, 23 January 2017
In version 4.3 and higher CONFIG DATABASE may use one of 3 methods for connecting to SQL Sources:
- DSN
- CONNECTSTRING
- ODBC-MANAGER
DSN
Syntax:
CONFIG DATABASE <db-ref> DSN=<dsn-ref> [, USER= <department> | LOGIN_NAME | ? ] [, {PASSWORD= <dept-password> | BR_PASSWORD | ? } | PASSWORD=<encrypted-password> ]
The ? indicates prompt
Example:
EXECUTE 'CONFIG DATABASE CLS_Data DSN="MyData"'
CONNECTSTRING (DSN Less)
Syntax:
CONFIG DATABASE <db-ref> CONNECTSTRING="<Driver>={Microsoft Access Driver (*.mdb)} DBQ=C:\inetpub\wwwroot\BegASP\Chapter.14\Contact.mdb"
Sample Connection Strings:
Using a SQL Server /w SQL Login:
CONFIG database db-ref connectstring="DRIVER=SQL Server;SERVER=server;Initial Catalog=database;UID=username;PWD=password"
"db-ref" is the database reference. "server" is the SQL Server [FQDN] or IP Address "database" is the [SQL Server Database] "username" is the [SQL Server User Name] "password" is the [SQL Server Password]
Using a SQL Server /w Windows Authentication:
CONFIG database db-ref connectstring="DRIVER=SQL Server;Initial Catalog=database;Persist Security Info=True;MultipleBC_TableResultSets=True; Database=database;SERVER=server;Login Name=username;Password=BR_PASSWORD"
"db-ref" is the database reference.
"server" is the SQL Server [FQDN] or IP Address
"database" is the [SQL Server Database]
"username" is the [SQL Server User Name]
BR_PASSWORD will use the users Active Directory password to connect to the SQL Server.
"SQL Server" is one of several choices for SQL Server, another choice would be SQL Server Native Client 11.0
ODBC-MANAGER
Syntax:
CONFIG DATABASE <db-ref> ODBC-MANAGER
Using ODBC Manager as the parameter will allow the end user to select the desired data source.
The following is a sample program that will use the ODBC-MANAGER to identify the proper connection string.
- Note: This will not work in Client Server *
00010 PRINT Newpage 00011 IF Env$("br_model")="CLIENT_SERVER" THEN PRINT "Warning, you cannot connect to ODBC-MANAGER in Client Server Mode" 00020 EXECUTE "config database Test_DB ODBC-MANAGER" ERROR CONNECT_ERROR 00030 PRINT "Connection String is:" !:
PRINT Env$("STATUS.DATABASE.[TEST_DB].CONNECTSTRING")
00099 STOP 00100 CONNECT_ERROR: ! 00110 PRINT "Error Connecting - Err:";Err;" Line:";Line;" Syserr:";Syserr$