another good spot is the App.Config file which allows for different conn
strings for different users... Enterprise Library uses this, I think.
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OMT06%23O6FHA.1248@TK2MSFTNGP14.phx.gbl...[color=blue]
> Re-create the connection as-needed from a constant connection string and
> allow connection pooling that's built in to the system to manage this for
> you.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
>
http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
>
http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
>
http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "Digital Fart" <progressdll@angelfire.com> wrote in message
> news:a0fgn1dblopectbu8l3cl98iuad0t0jvqr@4ax.com...[color=green]
>> howto make a connection to database available in my classes.
>>
>> What is the best practice when i want to write classes
>> that need a connection to the database?
>>
>> Do i make a conn variable in my main() and give
>> it as a parameter to every object i make that needs
>> access to the database
>>
>> ex.
>>
>> A class called Price that need to do
>> some bussines logic to a database.
>>
>> Price price = new price(param,param,connection)
>>
>> or do i connect to the database in every class
>> i build
>>
>> ex.
>>
>> A class called Price that does a connection itself.
>>
>> Price price = new price(param,param)
>>
>> or any better practice?
>>
>>[/color]
>
>[/color]