Making a SQL Call from a UI Model - connection string?

How do I get a connection string from the UI Model?


This doesn't seem to work:


this.HostModel.GetRequestContext().AppDBConnectionString();


(I'm using C#, that's why it's "this" and not "Me")



 

Comments

  • Hi Rick--this should work (will return an opened DB connection, hence the using):



      using (IDbConnection conn = GetRequestContext().OpenAppDBConnection())
  • Matt Hall:

    Hi Rick--this should work (will return an opened DB connection, hence the using):



      using (IDbConnection conn = GetRequestContext().OpenAppDBConnection())

    Thanks!


    I did figure out what part of my original code was wrong


    this.HostModel.GetRequestContext().AppDBConnectionString();


    So this also worked


    this.GetRequestContext().AppDBConnectionString();


    But I like your solution better.

Categories