IPrimaryODBCSPLD.ODBCParamValue

Syntax

ODBCParamValue(Name: String): Variant;

ODBCParamValue[Name: String]: Object;

Parameters

Name. Parameter name.

Description

The ODBCParamValueproperty determines a parameter value with the specified index.

Comments

Parameter names can be obtained in documentation for the ODBC driver, which was used for connection.

Example

The operating system must have Microsoft SQL Server ODBC driver installed. The network has a server named MSSQLServer, the DataRepository schema is created on the server.

Add links to the Db and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    DB: IDatabase;
    LogonData: IPrimaryODBCSPLD;
    PasswordCreds: IPasswordCredentials;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_DATABASE;
    CrInfo.Id := 
"ODBC_DB";
    CrInfo.Name := 
"Connection via ODBC1";
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit;
    DB := MObj 
As IDatabase;
    DB.Authentication := AuthenticationMode.Password;
    DB.DriverId := 
"ODBC";
    LogonData := DB.LogonData 
As IPrimaryODBCSPLD;
    LogonData.ODBCParamValue(
"DRIVER") := "{ODBC Driver 13 for SQL Server}";
    LogonData.ODBCParamValue(
"SERVER") := "MSSQLServer";
    LogonData.ODBCParamValue(
"DATABASE") := "DataRepository";
    DB.LoginPrompt := 
False;
    PasswordCreds := DB.Credentials 
As IPasswordCredentials;
    PasswordCreds.UserName := 
"User";
    PasswordCreds.Password := 
"Password";
    MObj.Save;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    DB: IDatabase;
    LogonData: IPrimaryODBCSPLD;
    PasswordCreds: IPasswordCredentials;
Begin
    MB := Params.Metabase;
    CrInfo := MB.CreateCreateInfo();
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_DATABASE 
As Integer;
    CrInfo.Id := 
"ODBC_DB";
    CrInfo.Name := 
"Connect via ODBC";
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit();
    DB := MObj 
As IDatabase;
    DB.Authentication := AuthenticationMode.amPassword;
    DB.DriverId := 
"ODBC";
    LogonData := DB.LogonData 
As IPrimaryODBCSPLD;
    LogonData.ODBCParamValue[
"DRIVER"] := "{ODBC Driver 13 for SQL Server}";
    LogonData.ODBCParamValue[
"SERVER"] := "MSSQLServer";
    LogonData.ODBCParamValue[
"DATABASE"] := "DataRepository";
    DB.LoginPrompt := 
False;
    PasswordCreds := DB.Credentials 
As IPasswordCredentials;
    PasswordCreds.UserName := 
"User";
    PasswordCreds.Password := 
"Password";
    MObj.Save();
End Sub;

After executing the example, a new database is create in the repository root folder, which allows for connecting to data sources via Microsoft SQL Server ODBC driver.

See also:

IPrimaryODBCSPLD