Getting identity column values – PB Docs 126

Getting identity column values

You can use the standard select @@identity syntax
to obtain the value of an identity column. You can also use an alternative
syntax, such as select scope_identity(),
by adding sections to a .NET configuration file for your application.

Setting up a dbConfiguration section in a configuration
file

The following example shows the general structure of a configuration
file with a database configuration section and one custom configuration
section:

proc.png To add a database configuration section to a .NET
configuration file:

  1. In the <configSections> section
    of the configuration file, add a <sectionGroup> element
    with the name “dbConfiguration”. This name is case-sensitive.

    <configSections> must appear at the beginning
    of the configuration file, before the <runtime> section
    if any.

  2. In the dbConfiguration <sectionGroup> element,
    add one of more <section> elements.

    For each section, specify a name of your choice and a type.
    The type is the strong name of the assembly used to parse this section
    of the configuration file.

  3. Close the <section> and <configSections> elements
    and add a <dbConfiguration> element.

  4. For each section you defined in step 2, add a
    new element to the <dbConfiguration> element.

    For example, if you defined a section called config1,
    add a config1 element. Each
    element has two attributes: dbParm and getIdentity. You can set
    either or both of these attributes.

    The dbParm value sets the value of the DbParameter parameter
    of the transaction object. It has a maximum length of 1000 characters.
    If you set a value for a parameter in the configuration file, any
    value that you set in code or in the Database Profile Setup dialog
    box is overridden.

    The getIdentity value specifies the syntax used to retrieve
    the value of an identity column. It has a maximum length of 100
    characters. If you do not specify a value for getIdentity, the select @@identity syntax
    is used.

Sample configuration file

This sample configuration file for PowerBuilder 12.6 is called pb126.exe.config.
It contains three custom configurations. The <myconfig> element
sets both the dbParm and getIdentity attributes. <myconfig1> sets getIdentity
only, and <myconfig2> sets dbParm only. The <runtime> section
is in the configuration file that ships with PowerBuilder but would
not be included in the configuration file that you ship with your
application, which would have the same name as your application
with the extension exe.config.

Specifying the custom configuration to be used

On the System tab page in the Database Profile Setup dialog
box for ADO.NET or in code, specify the name of the custom configuration
section you want to use as the value of the DbConfigSection parameter.
For example:

If you set any parameters in the profile or in code that are
also set in the configuration file, the value specified in the configuration
file takes precedence.

The configuration file must be present in the same directory
as the executable file and must have the same name with the extension
.config.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x