Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
Questiona question about using sn.exe - private key Pin
mhp13017-Jul-07 0:09
mhp13017-Jul-07 0:09 
AnswerRe: a question about using sn.exe - private key Pin
Mike Dimmick17-Jul-07 1:16
Mike Dimmick17-Jul-07 1:16 
Questiontwo commands are possible Pin
srinivassam16-Jul-07 23:52
srinivassam16-Jul-07 23:52 
AnswerRe: two commands are possible Pin
Nisar Inamdar16-Jul-07 23:59
Nisar Inamdar16-Jul-07 23:59 
AnswerRe: two commands are possible Pin
Mike Dimmick17-Jul-07 2:21
Mike Dimmick17-Jul-07 2:21 
QuestionRDLC Pin
manoj_ce16-Jul-07 23:37
manoj_ce16-Jul-07 23:37 
QuestionBest practice for ADO.NET and C# Pin
matbuk16-Jul-07 23:08
matbuk16-Jul-07 23:08 
AnswerRe: Best practice for ADO.NET and C# Pin
Colin Angus Mackay16-Jul-07 23:17
Colin Angus Mackay16-Jul-07 23:17 
matbuk wrote:
I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.


In .NET, not just C#, the guidelines suggest that you open a connection, perform your query and then close the connection. If you have multiple queries to perform in quick succession then you may keep the connection open for those queries.

.NET implements connection pooling so there is negligible performance hit after the connection is opened for the first time. Just ensure that each time you open a connection you use the exact same connection string.


matbuk wrote:
Then throughout the program i open the connection, perform the work and then close it afterwards.


Sounds good to me.


matbuk wrote:
Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??


I, personally, use new connection objects but keep the connection string the same.


matbuk wrote:
Is there a preferred or 'Best Practice' way of accessing a database throughout a program?


Create a DAL through which you access your database. Don't put database code in the presentation layer.


Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...

"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."

Ready to Give up - Your help will be much appreciated.


My website

GeneralRe: Best practice for ADO.NET and C# Pin
matbuk16-Jul-07 23:33
matbuk16-Jul-07 23:33 
GeneralRe: Best practice for ADO.NET and C# Pin
Colin Angus Mackay16-Jul-07 23:47
Colin Angus Mackay16-Jul-07 23:47 
GeneralRe: Best practice for ADO.NET and C# Pin
matbuk16-Jul-07 23:55
matbuk16-Jul-07 23:55 
QuestionCopying one class to another Pin
Berlus16-Jul-07 22:54
Berlus16-Jul-07 22:54 
AnswerRe: Copying one class to another Pin
Martin#16-Jul-07 23:00
Martin#16-Jul-07 23:00 
QuestionText on Video using DirectX Pin
Sukhjinder_K16-Jul-07 22:46
Sukhjinder_K16-Jul-07 22:46 
AnswerRe: Text on Video using DirectX Pin
Eduard Keilholz16-Jul-07 23:44
Eduard Keilholz16-Jul-07 23:44 
QuestionXML Serialization Pin
blackjack215016-Jul-07 22:46
blackjack215016-Jul-07 22:46 
AnswerRe: XML Serialization Pin
J4amieC16-Jul-07 23:36
J4amieC16-Jul-07 23:36 
GeneralRe: XML Serialization Pin
blackjack215017-Jul-07 1:03
blackjack215017-Jul-07 1:03 
QuestionSystem Files in Deployment Pin
RoyRose7816-Jul-07 22:30
RoyRose7816-Jul-07 22:30 
AnswerRe: System Files in Deployment Pin
Colin Angus Mackay16-Jul-07 22:33
Colin Angus Mackay16-Jul-07 22:33 
QuestionRDLC report problem Pin
manoj_ce16-Jul-07 22:17
manoj_ce16-Jul-07 22:17 
QuestionCrystal Report (beginner) Pin
T.EDY16-Jul-07 21:58
T.EDY16-Jul-07 21:58 
Questiondrawing shape that is allowed to drag and drop Pin
cyn816-Jul-07 20:17
cyn816-Jul-07 20:17 
AnswerRe: drawing shape that is allowed to drag and drop Pin
Bert delaVega17-Jul-07 6:18
Bert delaVega17-Jul-07 6:18 
QuestionHow to changeIME mode Pin
iprasad00716-Jul-07 19:58
iprasad00716-Jul-07 19:58 

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.