Click here to Skip to main content
16,004,761 members
Home / Discussions / C#
   

C#

 
GeneralCode Critique Requested Pin
mealnumberone23-Jun-04 7:49
mealnumberone23-Jun-04 7:49 
GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 8:38
Daniel Turini23-Jun-04 8:38 
GeneralRe: Code Critique Requested Pin
Heath Stewart23-Jun-04 8:50
protectorHeath Stewart23-Jun-04 8:50 
GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 9:00
Daniel Turini23-Jun-04 9:00 
GeneralRe: Code Critique Requested Pin
Heath Stewart23-Jun-04 9:06
protectorHeath Stewart23-Jun-04 9:06 
GeneralRe: Code Critique Requested Pin
mealnumberone23-Jun-04 9:11
mealnumberone23-Jun-04 9:11 
GeneralRe: Code Critique Requested Pin
Daniel Turini23-Jun-04 10:25
Daniel Turini23-Jun-04 10:25 
GeneralRe: Code Critique Requested Pin
Steven Campbell23-Jun-04 9:42
Steven Campbell23-Jun-04 9:42 
PositionsDB class should not be handling the connection itself. There are several reasons for this, but the most obvious is that the code would be duplicated in all of your database objects.

Better is to have the connection object created outside of your PositionsDB class, and then to pass that object as a parameter to PositionsDB. This allows much better flexibility in terms of transactions, as well as allowing other code to control the connection. The connection itself can be created by a Factory Method, (which just means a single piece of code that knows how to create the connection).

Experience has taught me that relying on terminators and dispose methods to close the database connection is not reliable; one or two slips and you will be leaking connections all over.

For handling the scope of the connection, I have found the C# using statement to be helpful, i.e. (pseudocode)
using (myConn = new Conn())<br />
{<br />
..do stuff with myConn<br />
}<br />

GeneralDataGrid and end edit Pin
cje23-Jun-04 6:44
cje23-Jun-04 6:44 
GeneralRe: DataGrid and end edit Pin
Heath Stewart23-Jun-04 8:40
protectorHeath Stewart23-Jun-04 8:40 
GeneralRe: DataGrid and end edit Pin
cje23-Jun-04 8:49
cje23-Jun-04 8:49 
GeneralRe: DataGrid and end edit Pin
Heath Stewart23-Jun-04 9:00
protectorHeath Stewart23-Jun-04 9:00 
GeneralRe: DataGrid and end edit Pin
cje23-Jun-04 9:04
cje23-Jun-04 9:04 
QuestionHow-to? Connect to remote pc over LAN connection ? Pin
Adel83k23-Jun-04 5:57
Adel83k23-Jun-04 5:57 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
eggie523-Jun-04 6:44
eggie523-Jun-04 6:44 
GeneralRe: How-to? Connect to remote pc over LAN connection ? Pin
Adel83k24-Jun-04 1:09
Adel83k24-Jun-04 1:09 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
Steven Campbell23-Jun-04 7:19
Steven Campbell23-Jun-04 7:19 
AnswerRe: How-to? Connect to remote pc over LAN connection ? Pin
sides_dale23-Jun-04 15:44
sides_dale23-Jun-04 15:44 
GeneralSuggestion Pin
vcorn23-Jun-04 5:23
vcorn23-Jun-04 5:23 
GeneralRe: Suggestion Pin
Werdna23-Jun-04 6:59
Werdna23-Jun-04 6:59 
QuestionHow to set row height of listview ? Pin
Old Gun23-Jun-04 5:16
Old Gun23-Jun-04 5:16 
AnswerRe: How to set row height of listview ? Pin
Werdna23-Jun-04 7:06
Werdna23-Jun-04 7:06 
GeneralReport Services nice printing Pin
Wally Wally23-Jun-04 2:48
Wally Wally23-Jun-04 2:48 
GeneralRe: Report Services nice printing Pin
Heath Stewart23-Jun-04 5:17
protectorHeath Stewart23-Jun-04 5:17 
QuestionCan you Draw Shapes on Forms/PictureBoxes? Pin
ZeldaFreak23-Jun-04 1:54
ZeldaFreak23-Jun-04 1:54 

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.