IDalODBCConnectionDescriptor.ODBCParamValue

Syntax

ODBCParamValue(Name: String): Variant;

ODBCParamValue[Name: String]: Object;

Parameters

Name. Parameter name.

Description

The ODBCParamValue property determines a value for parameter with the specified name.

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 a link to the Dal system assembly. In Fore.NET also add links to the WinForms.Utils system assembly.

Sub UserProc;
Var
    Driver: IDalDriver;
    ConDesc: IDalConnectionDescriptor;
    Params: IDalConnectionDescriptorParams;
    Con: IDalConnection;
    ParamsODBC: IDalODBCConnectionDescriptor;
Begin
    
// Connection driver
    Driver := New DalMsSql2012ODBCDriver.Create As IDalDriver;
    
// Connection description
    ConDesc := Driver.CreateDescriptor;
    Params := ConDesc.Params;
    
// Set up connection parameters
    Params.Find("Host BSTR").Value := "MSSQLServer";
    Params.Find(
"Database").Value := "DataRepository";
    Params.Find(
"User Name").Value := "User";
    Params.Find(
"Password").Value := "Password";
    
// Additional connection parameters
    ParamsODBC := ConDesc as IDalODBCConnectionDescriptor;
    ParamsODBC.ODBCParamValue(
"MultiSubnetFailover") := "Yes";
    ParamsODBC.ODBCParamValue(
"ApplicationIntent") := "ReadOnly";
    Con := ConDesc.CreateConnection;
    Con.Open;
    
If Con.IsDisconnected Then
        Debug.WriteLine(
"No connection.");
    
Else
        Debug.WriteLine(
"Connected successfully.");
    
End If;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.PiLibNet.Utils;

Public Shared Sub UserProc();
Var
    
// Connection driver
    Driver: IDalDriver = ComCreator.Instance.CoCreate<DalMsSql2012ODBCDriverClass>();
    ConDesc: IDalConnectionDescriptor;
    Params: IDalConnectionDescriptorParams;
    Con: IDalConnection;
    ParamsODBC: IDalODBCConnectionDescriptor;
Begin
    
// Connection description
    ConDesc := Driver.CreateDescriptor();
    Params := ConDesc.Params;
    
// Set up connection parameters
    Params.Find("Host BSTR").Value := "MSSQLServer";
    Params.Find(
"Database").Value := "DataRepository";
    Params.Find(
"User Name").Value := "User";
    Params.Find(
"Password").Value := "Password";
    
// Additional connection parameters
    ParamsODBC := ConDesc as IDalODBCConnectionDescriptor;
    ParamsODBC.ODBCParamValue[
"MultiSubnetFailover"] := "Yes";
    ParamsODBC.ODBCParamValue[
"ApplicationIntent"] := "ReadOnly";
    Con := ConDesc.CreateConnection();
    Con.Open();
    
If Con.IsDisconnected Then
        System.Diagnostics.Debug.WriteLine(
"No connection.");
    
Else
        System.Diagnostics.Debug.WriteLine(
"Connected successfully.");
    
End If;
End Sub;

After executing the example, a new connection to the specified server is created. The connection is implemented via ODBC driver with setting additional connection parameters. The connection result is displayed in the development environment console.

See also:

IDalODBCConnectionDescriptor