Click here to Skip to main content
15,885,278 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: :'-( Pin
Alan Burkhart1-Aug-12 17:28
Alan Burkhart1-Aug-12 17:28 
GeneralRe: :'-( Pin
ExcellentOrg31-Jul-12 23:41
ExcellentOrg31-Jul-12 23:41 
JokeRe: :'-( Pin
dan!sh 1-Aug-12 1:46
professional dan!sh 1-Aug-12 1:46 
GeneralRe: :'-( Pin
jim lahey30-Jul-12 23:29
jim lahey30-Jul-12 23:29 
GeneralRe: :'-( Pin
CDP180231-Jul-12 1:22
CDP180231-Jul-12 1:22 
GeneralRe: :'-( Pin
jim lahey31-Jul-12 1:27
jim lahey31-Jul-12 1:27 
GeneralRe: :'-( Pin
RobCroll31-Jul-12 15:02
RobCroll31-Jul-12 15:02 
GeneralRe: :'-( Pin
woosterprogrammer1-Aug-12 1:51
woosterprogrammer1-Aug-12 1:51 
I am trying to learn better development practices so I would gratified if somebody could confirm what I see as well as show me the ideal replacement for this code.
Issues with the code
1) Sending in a SQL statement seems to be invitation for SQL injection
2) Exception handling seems to have been done exclusively so that the end user never sees a problem and nothing else
3) The Dispose statements seem to be useless .

Now is it good practice to open and close database connections , I have been reading elsewhere about using the Singleton pattern for database connections which in some cases do leave the connection open. Why is it essential to use dispose for the objects that were declared inside the function ? We know that they will be returned to the GC as soon as the function exits.
GeneralRe: :'-( Pin
Schmuli1-Aug-12 3:00
Schmuli1-Aug-12 3:00 
GeneralRe: :'-( Pin
woosterprogrammer1-Aug-12 6:28
woosterprogrammer1-Aug-12 6:28 
GeneralRe: :'-( Pin
Schmuli5-Aug-12 21:45
Schmuli5-Aug-12 21:45 
GeneralRe: :'-( Pin
woosterprogrammer7-Aug-12 1:49
woosterprogrammer7-Aug-12 1:49 
GeneralRe: :'-( Pin
Schmuli7-Aug-12 21:03
Schmuli7-Aug-12 21:03 
GeneralRe: :'-( Pin
woosterprogrammer8-Aug-12 1:28
woosterprogrammer8-Aug-12 1:28 
GeneralRe: :'-( Pin
BobJanova1-Aug-12 23:00
BobJanova1-Aug-12 23:00 
GeneralRe: :'-( Pin
Pete O'Hanlon1-Aug-12 23:09
mvePete O'Hanlon1-Aug-12 23:09 
GeneralRe: :'-( Pin
BobJanova2-Aug-12 1:38
BobJanova2-Aug-12 1:38 
GeneralRe: :'-( Pin
CDP18022-Aug-12 3:31
CDP18022-Aug-12 3:31 
GeneralRe: :'-( Pin
bjarneds1-Aug-12 23:31
bjarneds1-Aug-12 23:31 
GeneralRe: :'-( Pin
Gary Huck1-Aug-12 3:40
Gary Huck1-Aug-12 3:40 
GeneralRe: :'-( Pin
Schmuli1-Aug-12 3:01
Schmuli1-Aug-12 3:01 
GeneralRe: :'-( Pin
Dave Kreskowiak1-Aug-12 4:59
mveDave Kreskowiak1-Aug-12 4:59 
GeneralRe: :'-( Pin
reilly961-Aug-12 7:42
reilly961-Aug-12 7:42 
GeneralRe: :'-( Pin
spencepk3-Aug-12 14:37
spencepk3-Aug-12 14:37 
GeneralRe: :'-( Pin
AspDotNetDev3-Aug-12 14:43
protectorAspDotNetDev3-Aug-12 14:43 

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.