Click here to Skip to main content
15,915,319 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Close any opened Connections to a database? Pin
Ashfield3-Dec-09 20:53
Ashfield3-Dec-09 20:53 
GeneralRe: How to Close any opened Connections to a database? Pin
Shorgov3-Dec-09 22:09
Shorgov3-Dec-09 22:09 
GeneralRe: How to Close any opened Connections to a database? Pin
Ashfield4-Dec-09 1:09
Ashfield4-Dec-09 1:09 
GeneralRe: How to Close any opened Connections to a database? Pin
Shorgov4-Dec-09 5:32
Shorgov4-Dec-09 5:32 
QuestionReturning date time as null Pin
Joe Rozario3-Dec-09 5:07
Joe Rozario3-Dec-09 5:07 
AnswerRe: Returning date time as null [modified] Pin
0x3c03-Dec-09 5:09
0x3c03-Dec-09 5:09 
GeneralRe: Returning date time as null Pin
Joe Rozario3-Dec-09 5:15
Joe Rozario3-Dec-09 5:15 
GeneralRe: Returning date time as null Pin
0x3c03-Dec-09 5:37
0x3c03-Dec-09 5:37 
You replace private DateTime convertByteToDatetime(byte[] Data) with private Nullable<DateTime> convertByteToDatetime(byte[] Data). Then you can either return new Nullables, or just keep your code and rely on the implicit operators. If you do that, you don't need to do anything apart from checking HasValue in your calling code. If that's true, then retrieve value.

Example:
C#
Nullable<DateTime> nullableDate = convertByteToDatetime(new byte[] {0, 0, 0});

if(nullableDate.HasValue)
    //your date time is in nullableDate.Value
else
    //something bad happened.

However, please be aware that this will call your code to fail silently. I would personally raise an event detailing the exception before I return null so that I know precisely what went wrong without having to sprinkle try-catch blocks everywhere.


GeneralRe: Returning date time as null Pin
Joe Rozario3-Dec-09 5:41
Joe Rozario3-Dec-09 5:41 
AnswerRe: Returning date time as null Pin
PIEBALDconsult3-Dec-09 5:10
mvePIEBALDconsult3-Dec-09 5:10 
GeneralRe: Returning date time as null Pin
Joe Rozario3-Dec-09 5:18
Joe Rozario3-Dec-09 5:18 
GeneralRe: Returning date time as null Pin
PIEBALDconsult3-Dec-09 5:20
mvePIEBALDconsult3-Dec-09 5:20 
AnswerRe: Returning date time as null [modified] Pin
Luc Pattyn3-Dec-09 5:44
sitebuilderLuc Pattyn3-Dec-09 5:44 
GeneralRe: Returning date time as null Pin
Joe Rozario3-Dec-09 6:00
Joe Rozario3-Dec-09 6:00 
GeneralRe: Returning date time as null Pin
PIEBALDconsult3-Dec-09 10:45
mvePIEBALDconsult3-Dec-09 10:45 
AnswerRe: Returning date time as null Pin
souidi abderrahman3-Dec-09 5:58
souidi abderrahman3-Dec-09 5:58 
AnswerRe: Returning date time as null Pin
PIEBALDconsult3-Dec-09 8:23
mvePIEBALDconsult3-Dec-09 8:23 
GeneralRe: Returning date time as null Pin
Luc Pattyn3-Dec-09 9:02
sitebuilderLuc Pattyn3-Dec-09 9:02 
QuestionC# application to sort SQL database data and output to CSV file Pin
totally_stumped3-Dec-09 4:38
totally_stumped3-Dec-09 4:38 
AnswerRe: C# application to sort SQL database data and output to CSV file Pin
dan!sh 3-Dec-09 4:55
professional dan!sh 3-Dec-09 4:55 
AnswerRe: C# application to sort SQL database data and output to CSV file Pin
Shorgov3-Dec-09 5:13
Shorgov3-Dec-09 5:13 
AnswerRe: C# application to sort SQL database data and output to CSV file Pin
PIEBALDconsult3-Dec-09 5:15
mvePIEBALDconsult3-Dec-09 5:15 
QuestionKilling threads on form closing... Pin
Jacob Dixon3-Dec-09 2:59
Jacob Dixon3-Dec-09 2:59 
AnswerRe: Killing threads on form closing... Pin
Luc Pattyn3-Dec-09 3:12
sitebuilderLuc Pattyn3-Dec-09 3:12 
GeneralRe: Killing threads on form closing... Pin
Jacob Dixon3-Dec-09 3:19
Jacob Dixon3-Dec-09 3:19 

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.