ODBCParams: String;
ODBCParams: String;
The ODBCParams property determines a string of additional parameters values.
Parameters and their values are specified as parameter1=value1;parameter2=value2....
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 := "Connect via ODBC";
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.ODBCParams := "DRIVER={ODBC Driver 13 for SQL Server};SERVER=MSSQLServer;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.ODBCParams := "DRIVER={ODBC Driver 13 for SQL Server};SERVER=MSSQLServer;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: