Skip to content

CreateSqlParameter2 Function

NileshGhodekar edited this page Mar 18, 2018 · 5 revisions

Syntax

DbParameter CreateSqlParameter2(sqlConnectionStringConfigKey:string, parameterName:string, parameterDirection:string, parameterType:string [, parameterSize:integer, parameterValue:object])

Description

Creates a SqlParameter or OdbcParameter or DbParameter object. While this function provides more control over defining a SqlParameter, the CreateSqlParameter function is expected to be sufficient for most typical need of creating an "Input" parameter.

Remarks

To use this function, first define a Connection String in the FIMService application config file (Microsoft.ResourceManagement.Service.exe.config) and restart the FIMService. Only Native SQL Server and ODBC .Net Framework data providers are supported. An example of Native SQL Server and ODBC connection strings is listed below:

<configuration>
   <connectionStrings>
    <add name="AuxDB" connectionString="Data Source=IDSYS.CONTOSO.COM;Initial Catalog=FIMAuxiliaryDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

    <add name="AuxDB_ODBC" connectionString="DRIVER={SQL Server Native Client 11.0};SERVER=IDSYS.CONTOSO.COM;DATABASE=FIMAuxiliaryDB;Trusted_Connection=Yes;APP=MIMWAL;" providerName="System.Data.Odbc" />
  </connectionStrings>
</configuration>

If the connection strings contain SQL User's password, it is highly recommended that you do not leave them unencrypted. The connection strings section can be encrypted using the helper script EncryptConnectionString.ps1 included in the project source code.

The parameter names must start with an "@".

Possible values for the parameter direction are "Input", "Output", "InputOutput" and "ReturnValue".

Possible values for the parameter type are "Int", "NVarChar", "Bit" or any other SqlDBType or OdbcType or DbType enumeration values. Check Configuring Parameters and Parameter Data Types for a comparison of DbType, SqlDBType and OdbcType

Use CreateSqlParameter or CreateSqlParameter2 function to create parameters for the ExecuteSqlScalar and ExecuteSqlNonQuery functions.

Supported Version

2.17.0414.0

Examples

CreateSqlParameter2("AuxDB","@AccountName", "Output", "NVarChar", 20)

CreateSqlParameter2("AuxDB","@EmployeeID", "Output", "Int")

Clone this wiki locally