P&W FAQ - .NET

Pagina: 1
Acties:
  • 169 views sinds 30-01-2008

Acties:
  • 0 Henk 'm!

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

Topicstarter

Programming & Webscripting FAQ: .NET

· ^

FAQ

· ^

Waar zet ik het beste een connectionstring?

De connectie-string zet je het best in je web.config. (Dit is ook te lezen in de best practices van Microsoft vermoed ik).

In de web.config kan je een sectie 'appSettings' bijmaken:

XML:
1
2
3
4
5
<appSettings>

  <add key="connstring"
           value="hier komt de connectie-string" />
</appSettings>

Die connectiestring kan je dan makkelijk in uw code ophalen door gebruik te maken van het ConfigurationSettings object:

ASP.NET:
1
2
3
using System.Configuration;
....
string connstr = ConfigurationSettings.AppSettings["connstr"];

Over het hebben van 1 connectie die je overal kunt gebruiken:

Aangezien je gebruik kunt maken van connection pooling, is het beter om iedere keer een nieuw connectie-object te maken wanneer je het nodig hebt, en van zodra je geen database-connectie meer nodig hebt, die connectie te sluiten.

Zie ook:

  • Connection pooling for SQL Server data provider (ADO.NET)
  • Uit dit artikel:

    ADO.NET Connection
    You use the ADO.NET Connection object to create a connection between your program and a database engine. You will normally keep this connection open just long enough to retrieve or update data. By quickly opening, then closing a connection, you use server resources for as little time as possible. This helps you develop scalable, fast applications that are resource-friendly. The fewer resources you use, the more users you can support on your applications at one time.

· ^

Links

· ^

Boeken

ADO.NET

  • ADO.NET Programming

    Door: Arlen Feldman
    ISBN: 1930110294
    Manning Publications

ASP.NET

  • ASP.NET Unleashed

    Door: Stephen Walther
    ISBN: 0672320681
    Sams publishing

  • ASP.NET Website Programming: Problem - Design - Solution C# Edition

    Door: Marco Bellinaso, Kevin Hoffman
    ISBN: 1861006934
    Wrox Press

  • Professional ASP.NET

    Door: Alex Homer, Brian Francis, David Sussman, Karli Watson, Richard Anderson, Rob Howard
    ISBN: 1861004885
    Wrox press

C#

  • Professional C#, Second Edition

    Door: Simon Robinson, K. Scott Allen, Ollie Cornes, Jay Glynn, Zach Greenvoss, Burton Harvey, Christian Nagel, Morgan Skinner, Karli Watson
    ISBN: 0764543989
    Wrox Press

  • C# and the .NET Platform

    Door: Andrew Troelsen
    ISBN: 1893115593
    APress

  • Learning C# (2nd edition)

    Door: Jesse Liberty
    ISBN: 0596003765
    O'Reilly & Associates inc.

[ Voor 157% gewijzigd door NMe op 13-05-2005 17:40 ]

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Dit topic is gesloten.