The SmsDataSourceConnect function connects to the site database that your application will access.
SMS_STATUS SmsDataSourceConnect(
DATASOURCE *pd, // Pointer to DATASOURCE union containing the
// connection information.
HANDLE *phConn // Pointer to handle to receive connection handle.
);
For an example of encryption and decryption functions and how they are used with SmsDataSourceConnect, see Sample Decryption and Encryption Functions.
The SmsDataSourceConnect function returns a status code SMS_STATUS. If successful, the function returns a status of SMS_OK. Otherwise, it returns one of the following manifest constants:
SmsDataSourceConnect assigns a connection handle to the specified handle. Your application uses the handle to open, access, and close containers for that site database.
Currently, SMS supports one database type: Microsoft SQL Server. However, the SMS API is designed to allow support of other types of databases in the future.
Note that your application can connect to one site database at a time. In addition, your application can have only one connection to that site database.
After your application has finished accessing the site database, it should free the connection by calling the SmsDataSourceDisconnect function.
The following example connects to a SQL Server JS1 with a site database SMSBritain using login identifier jonathan and password hermes.
HANDLE hConnect;
DATASOURCE dsParams;
dsParams.sqlParams.ds = DB_SQL;
dsParams.sqlParams.pszServer = "JS1";
dsParams.sqlParams.pszUserName = "jonathan";
dsParams.sqlParams.pszPasswd = "hermes";
dsParams.sqlParams.pszDbName = "SMSBritain";
dsParams.sqlParams.pFunc = NULL;
dsParams.sqlParams.pszKey = "";
stat = SmsDataSourceConnect( &dsParams, &hConnect );