Click here to Skip to main content
15,912,329 members
Home / Discussions / C#
   

C#

 
GeneralRe: restart application Pin
Ravenet11-Feb-08 13:32
Ravenet11-Feb-08 13:32 
GeneralRe: restart application Pin
Xmen Real 11-Feb-08 14:49
professional Xmen Real 11-Feb-08 14:49 
GeneralTextboxs and buttons visible true and false problem Pin
raghu.chanti11-Feb-08 0:07
raghu.chanti11-Feb-08 0:07 
GeneralRe: Textboxs and buttons visible true and false problem Pin
imsathy11-Feb-08 0:33
imsathy11-Feb-08 0:33 
GeneralMaking Textbox Multilingual Pin
D i x y10-Feb-08 22:50
D i x y10-Feb-08 22:50 
GeneralDataGridView - DataGridViewComboBoxCell Pin
Harvey Saayman10-Feb-08 22:39
Harvey Saayman10-Feb-08 22:39 
Generalhelp for opengl in c# Pin
faisalharoon10-Feb-08 20:50
faisalharoon10-Feb-08 20:50 
GeneralRe: help for opengl in c# Pin
User 665810-Feb-08 22:00
User 665810-Feb-08 22:00 
GeneralRe: help for opengl in c# Pin
Pete O'Hanlon10-Feb-08 22:03
mvePete O'Hanlon10-Feb-08 22:03 
GeneralConnection string problem Pin
D i x y10-Feb-08 20:06
D i x y10-Feb-08 20:06 
GeneralRe: Connection string problem Pin
N a v a n e e t h10-Feb-08 20:16
N a v a n e e t h10-Feb-08 20:16 
GeneralRe: Connection string problem Pin
Rupesh Kumar Swami10-Feb-08 20:33
Rupesh Kumar Swami10-Feb-08 20:33 
GeneralRe: Connection string problem Pin
Mircea Puiu10-Feb-08 23:17
Mircea Puiu10-Feb-08 23:17 
GeneralRe: Connection string problem [modified] Pin
Harvey Saayman11-Feb-08 0:28
Harvey Saayman11-Feb-08 0:28 
GeneralRe: Connection string problem Pin
Pete O'Hanlon11-Feb-08 2:37
mvePete O'Hanlon11-Feb-08 2:37 
HarveySaayman wrote:
if u make a new connection every time u want to get data from a database you cause unnecicary overhead and lag when you are opening the window (assuming u make the connection OnFormLoad)

what you sould be doing is making a connection when the program starts up in the Main() method

then when you open a new window u send the instance of the dataBaseConnection to that form


WTF | :WTF: Tell me you're joking. Please.

This is the worst thing that you could do. When you do this, you have opened a persistent connection to the database which doesn't get closed until your application exits. This means that your application isn't scalable. More importantly, it doesn't cater for the fact that the database may go down and come back up between calls. If this happens, then your connection is no longer valid.

The general rule is acquire a connection as late as possible and release it as early as possible because a connection is a "precious" resource. If you have pooling enabled, then new connections will merely pull the connection from the pool (dependent on the connection string you pass in).

The correct way to do this (from .NET 2 on) is to put an entry in the ConnectionStrings section in the config file. Then use ConfigurationManager.ConnectionStrings["ConnectionStringNameHere"].ConnectionString to retrieve the actual connection string.


Deja View - the feeling that you've seen this post before.

My blog | My articles



GeneralRe: Connection string problem Pin
Harvey Saayman11-Feb-08 22:57
Harvey Saayman11-Feb-08 22:57 
GeneralRe: Connection string problem Pin
Dave Kreskowiak11-Feb-08 3:49
mveDave Kreskowiak11-Feb-08 3:49 
GeneralRe: Connection string problem Pin
Pete O'Hanlon11-Feb-08 2:41
mvePete O'Hanlon11-Feb-08 2:41 
GeneralRe: Connection string problem Pin
D i x y11-Feb-08 17:06
D i x y11-Feb-08 17:06 
GeneralRe: Connection string problem Pin
Harvey Saayman11-Feb-08 20:35
Harvey Saayman11-Feb-08 20:35 
GeneralRe: Connection string problem Pin
Ravenet11-Feb-08 3:10
Ravenet11-Feb-08 3:10 
QuestionHow to Add a Font in Setup Project Pin
Bajrang Singh10-Feb-08 20:04
Bajrang Singh10-Feb-08 20:04 
AnswerRe: How to Add a Font in Setup Project Pin
Rupesh Kumar Swami10-Feb-08 20:18
Rupesh Kumar Swami10-Feb-08 20:18 
AnswerRe: How to Add a Font in Setup Project Pin
Giorgi Dalakishvili10-Feb-08 20:25
mentorGiorgi Dalakishvili10-Feb-08 20:25 
GeneralRe: How to Add a Font in Setup Project Pin
Rupesh Kumar Swami10-Feb-08 20:39
Rupesh Kumar Swami10-Feb-08 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.