locked
Microsoft Enterprise Library RRS feed

  • Question

  • User-1097933300 posted

    Hi all,

    I'm new to using Microsoft Enterprise Library,
    I was wondering if I need to call the CreateDatabase method every time I'm calling a stored procedure or do I need to do it only once and if so where do I initialize it and how do I then make use of it?!

    Thanks for your help

    Friday, January 14, 2011 8:13 AM

Answers

  • User712082397 posted

    Does CreateDatabase need to run on each database access?

     

    No, does not need to be called everytime you access database. Call this once and save it in a class level variable and use it for further processing.

    If you want to do it on an application level, probably, you can try saving it in application object in ASP.NET and use it from there.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 19, 2011 1:10 PM

All replies

  • User1508394307 posted

    You can create it once as a class variable and use it where you need it

    Database db = DatabaseFactory.CreateDatabase();
    DataSet ds = db.ExecuteDataSet("dbo.proc1", new string[] { "id" });

    Friday, January 14, 2011 8:28 AM
  • User-1097933300 posted

    Can I create it at a level more general than the class like somewhere that the whole website can use it?!

    Friday, January 14, 2011 8:30 AM
  • User1508394307 posted

    What could be more general than the class? ;-)

    Friday, January 14, 2011 9:08 AM
  • User-1097933300 posted

    ok, tell me this

    Does CreateDatabase need to run on each database access?

    Friday, January 14, 2011 9:13 AM
  • User712082397 posted

    Does CreateDatabase need to run on each database access?

     

    No, does not need to be called everytime you access database. Call this once and save it in a class level variable and use it for further processing.

    If you want to do it on an application level, probably, you can try saving it in application object in ASP.NET and use it from there.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 19, 2011 1:10 PM
  • User-1097933300 posted

    Is that a good practice to declare it at application level?
    How about a session variable?!

    Tuesday, January 25, 2011 11:52 AM
  • Tuesday, January 25, 2011 12:51 PM