Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
AnswerRe: Convert Asp.net web application App_Code folder to DLL Pin
shubham salwan12-Jul-12 9:25
shubham salwan12-Jul-12 9:25 
AnswerRe: Convert Asp.net web application App_Code folder to DLL Pin
ZurdoDev12-Jul-12 10:58
professionalZurdoDev12-Jul-12 10:58 
QuestionC# execute reader to liste Pin
coucou00812-Jul-12 4:02
coucou00812-Jul-12 4:02 
AnswerRe: C# execute reader to liste Pin
BobJanova12-Jul-12 4:08
BobJanova12-Jul-12 4:08 
GeneralRe: C# execute reader to liste Pin
coucou00812-Jul-12 7:24
coucou00812-Jul-12 7:24 
GeneralRe: C# execute reader to liste Pin
Ennis Ray Lynch, Jr.12-Jul-12 4:42
Ennis Ray Lynch, Jr.12-Jul-12 4:42 
AnswerRe: C# execute reader to liste Pin
Luc Pattyn12-Jul-12 8:34
sitebuilderLuc Pattyn12-Jul-12 8:34 
GeneralRe: C# execute reader to liste Pin
Ennis Ray Lynch, Jr.12-Jul-12 8:53
Ennis Ray Lynch, Jr.12-Jul-12 8:53 
I omit the using on SqlCommand for brevity since its sole function is to close the connection. However, on the data reader, there are times when you want to re-use the command but you can't re-use a command with an open reader. This lets it be much, much easier to not have to fix that bug.

With regard to the constructor, it is matter of taste and I will never fault anyone for using it. Unfortunately, I a lot of my code is left to be maintained by others. I like to think that the brilliance in the code I write is not only in its function but in the ability to line-by-line debug without any surprises.

In my younger career I used to use stored procedures exclusively. I have now moved to embedding the SQL statments in the source files for easier version control. With this, sometimes comes complex dynamic sql statements. (Especially, when reading from SQL Server and then Selecting from Oracle, ugh) with a monstrosity like that, I really don't want to use the constructor because then you have to step into a method in a constructor to see what it does when stepping over an examining the results is so much easier.

Finally, and I never use it, don't forget the option to immediately close the command in command.ExecuteReader().
<br />
command.ExecuteReader(CommandBehavior.CloseConnection);<br />


Really, there are so many great ways to write good clean code using data readers over the hide-and-seek approach that so many ORM's use that I am surprised more developers don't just go back to the basics. I have spent more time debugging one bug in Entity Framework than in debugging every line of the code we are discussing ever. (Ok, that is hyperbole but you get my drift)

Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS.

"And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

GeneralRe: C# execute reader to liste Pin
Luc Pattyn12-Jul-12 9:17
sitebuilderLuc Pattyn12-Jul-12 9:17 
GeneralRe: C# execute reader to liste Pin
jschell12-Jul-12 10:24
jschell12-Jul-12 10:24 
GeneralRe: C# execute reader to liste Pin
Eddy Vluggen12-Jul-12 9:17
professionalEddy Vluggen12-Jul-12 9:17 
AnswerRe: C# execute reader to liste Pin
Luc Pattyn12-Jul-12 9:30
sitebuilderLuc Pattyn12-Jul-12 9:30 
GeneralRe: C# execute reader to liste Pin
coucou00812-Jul-12 22:43
coucou00812-Jul-12 22:43 
AnswerRe: C# execute reader to liste Pin
Matt T Heffron13-Jul-12 8:08
professionalMatt T Heffron13-Jul-12 8:08 
Questionhow to save data Pin
shubham salwan12-Jul-12 1:56
shubham salwan12-Jul-12 1:56 
AnswerRe: how to save data Pin
Eddy Vluggen12-Jul-12 2:28
professionalEddy Vluggen12-Jul-12 2:28 
AnswerRe: how to save data Pin
KSaiPrasad12-Jul-12 3:09
KSaiPrasad12-Jul-12 3:09 
GeneralRe: how to save data PinPopular
PIEBALDconsult12-Jul-12 3:55
mvePIEBALDconsult12-Jul-12 3:55 
GeneralRe: how to save data Pin
shubham salwan12-Jul-12 8:43
shubham salwan12-Jul-12 8:43 
GeneralRe: how to save data Pin
PIEBALDconsult13-Jul-12 3:49
mvePIEBALDconsult13-Jul-12 3:49 
GeneralRe: how to save data Pin
shubham salwan12-Jul-12 8:26
shubham salwan12-Jul-12 8:26 
GeneralRe: how to save data Pin
KSaiPrasad12-Jul-12 19:15
KSaiPrasad12-Jul-12 19:15 
GeneralRe: how to save data Pin
shubham salwan12-Jul-12 20:11
shubham salwan12-Jul-12 20:11 
AnswerRe: how to save data Pin
Simon_Whale12-Jul-12 3:17
Simon_Whale12-Jul-12 3:17 
AnswerRe: how to save data Pin
BobJanova12-Jul-12 4:08
BobJanova12-Jul-12 4:08 

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.