locked
Biztalkserver Mapping: Dynamic Connection String RRS feed

  • Question

  • Hi All,

    Please tell me the easy way to get the connection string dynamically in biztalk mapping from two databases but from same server.

    e.g: SourceField   DestinationField    DatabaseUsedForDBLookupFunctoid

    AB                               X1                          DB1

    CD                               X2                          DB2

     

     

    Urgent Please..........

     



    Thursday, October 6, 2011 7:22 AM

Answers

  • so if one works just replicate that and put another key in config file for the second connection string. You will have to create another scripting functoid and use the same C# library component's different method.

    You can use this code snippet to get the biztalk config file value.

    System.Configuration.ConfigurationSettings.AppSettings.Get("Key");



    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.

    • Edited by DPS Bali Thursday, October 6, 2011 10:57 AM
    • Proposed as answer by SKGuru Friday, October 7, 2011 1:08 PM
    • Marked as answer by Lloyd ZhangModerator Thursday, October 13, 2011 6:29 AM
    Thursday, October 6, 2011 10:50 AM

All replies

  • I assume there will be two database lookup functoids in your map for the two fields AB and CD that you are mapping, if so you don't need any dynamic connection string. You can easily put two seperate connections strings in two functoids . Hope I understood your requirement correctly.
    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Thursday, October 6, 2011 8:52 AM
  • Thanks for the reply.

    Yes there will be two DB look up functoids. But I dont want to Hard code it. I want to get the connection string dynamically.

    So please tell me the easiest possible way to get the Connection string dynamically.

     

     

     

     

    Thursday, October 6, 2011 9:07 AM
  • You can use a C# library and use a scripting functoid to get the info or you can use a SQL UDL from a file location but the latter is an overhead. So the best way would be to get the configurable property from C# library in a scripting functoid and use that to create the connection string .
    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Thursday, October 6, 2011 10:06 AM
  • I did it and I have editted in BTS config file. But connection string is getting only for one DB only. Could you please send me the brief code if possible.

     

    Thanks in advace

    Thursday, October 6, 2011 10:46 AM
  • so if one works just replicate that and put another key in config file for the second connection string. You will have to create another scripting functoid and use the same C# library component's different method.

    You can use this code snippet to get the biztalk config file value.

    System.Configuration.ConfigurationSettings.AppSettings.Get("Key");



    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.

    • Edited by DPS Bali Thursday, October 6, 2011 10:57 AM
    • Proposed as answer by SKGuru Friday, October 7, 2011 1:08 PM
    • Marked as answer by Lloyd ZhangModerator Thursday, October 13, 2011 6:29 AM
    Thursday, October 6, 2011 10:50 AM
  • Exactly I have the same scenario, In database lookup functoid, I am taking 2nd parameter as scripting functoid as Inline c#

    public string GetConnectionString()
       {
                   string connString=System.Configuration.ConfigurationSettings.AppSettings.Get("CONNSTR").ToString();
                   return connString;
        }
    

    and then in BTSNTSvc64.exe.config file when I am adding this to Configuration :

    <appsettings>
        <add key="CONNSTR" value="Provider=SQLOLEDB.1;Server=12121KP035;Database=TestDatabase;Integrated Security=SSPI"/>
      </appsettings>

    all my service instance are getting blown away ? what am I doing wrong ?


    MBH

    Sunday, May 3, 2015 8:48 PM