Connection string custom attributes

  • Hello,

    I have to add a custom parameter to the connection string (i cannot re-use other attributes like workstation id). Making some tests everything looks ok, for example:

    Provider=SQLOLEDB;Data Source=myServer; Integrated Security=SSPI; Initial Catalog=myDatabase; NewAttribute='TestAttributeValue'

    works fine (is not triggering errors when i connect to the server). But i don't know how can i access it in t-sql. Can you please help me? Is it possible to do something like this?

    Thank you

  • via tsql, those custom attributes are not exposed, i think.

    the application name and the host name are...if you do not provide it explicitly, the driver populates it for you automatically, so you can get them like this:

    /*--results

    (No column name)(No column name)

    STORMDEVMicrosoft SQL Server Management Studio

    */

    select host_name(), app_name()

    if you provide the appname or host name, you override that functionality, like this:

    Private Const SqlConnectionFormat As String = "data source={0};

    initial catalog={1};

    user id={2};

    password={3};

    Trusted_Connection=False;

    Workstation ID=Ghost In The Machine;

    Application Name=HaxxorPadPlusPlus;"

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply