Click here to Skip to main content
15,913,486 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionData Conversions Pin
Bram van Kampen9-Jun-13 14:17
Bram van Kampen9-Jun-13 14:17 
AnswerRe: Data Conversions Pin
Abhinav S9-Jun-13 16:33
Abhinav S9-Jun-13 16:33 
AnswerRe: Data Conversions Pin
Richard MacCutchan9-Jun-13 21:12
mveRichard MacCutchan9-Jun-13 21:12 
GeneralRe: Data Conversions Pin
Richard Deeming10-Jun-13 1:39
mveRichard Deeming10-Jun-13 1:39 
GeneralRe: Data Conversions Pin
Richard MacCutchan10-Jun-13 1:44
mveRichard MacCutchan10-Jun-13 1:44 
AnswerRe: Data Conversions Pin
Richard Deeming10-Jun-13 1:40
mveRichard Deeming10-Jun-13 1:40 
GeneralRe: Data Conversions Pin
Bram van Kampen11-Jun-13 13:11
Bram van Kampen11-Jun-13 13:11 
AnswerRe: Data Conversions Pin
Ron Beyer10-Jun-13 3:07
professionalRon Beyer10-Jun-13 3:07 
You should probably be using the SqlDataReader GetXXXX functions, like:

myReader.GetInt32(X) -> where X is the Column INDEX (not the name). Its unfortunate that these functions only work on the index, but you could also do:

C#
myReader.GetInt32(myReader.GetOrdinal(columnName))


The only thing you have to do (and you do with your code above too, but you haven't encountered the error yet) is to check for null values on that column before trying to retrieve the values. Trying to read a NULL value as an Integer will give you an exception (it doesn't with string or object because null is implicitly convertible to both).

Link to MSDN article that shows the Get functions.[^]
QuestionExecution time difference between VB.Net and C# code Pin
TnTinMn9-Jun-13 11:36
TnTinMn9-Jun-13 11:36 
AnswerRe: Execution time difference between VB.Net and C# code Pin
Bram van Kampen9-Jun-13 14:37
Bram van Kampen9-Jun-13 14:37 
GeneralRe: Execution time difference between VB.Net and C# code Pin
TnTinMn9-Jun-13 16:00
TnTinMn9-Jun-13 16:00 
AnswerRe: Execution time difference between VB.Net and C# code Pin
Ron Beyer9-Jun-13 19:05
professionalRon Beyer9-Jun-13 19:05 
GeneralRe: Execution time difference between VB.Net and C# code Pin
TnTinMn10-Jun-13 3:59
TnTinMn10-Jun-13 3:59 
QuestionDisplay Comments in winforms Pin
Member 100156599-Jun-13 5:04
Member 100156599-Jun-13 5:04 
AnswerRe: Display Comments in winforms Pin
Abhinav S9-Jun-13 5:23
Abhinav S9-Jun-13 5:23 
QuestionHow The data by jquery Pin
hansraj.sm5-Jun-13 20:52
hansraj.sm5-Jun-13 20:52 
AnswerRe: How The data by jquery Pin
Richard MacCutchan5-Jun-13 21:15
mveRichard MacCutchan5-Jun-13 21:15 
AnswerRe: How The data by jquery Pin
Abhinav S5-Jun-13 22:14
Abhinav S5-Jun-13 22:14 
AnswerRe: How The data by jquery Pin
Pete O'Hanlon5-Jun-13 22:20
mvePete O'Hanlon5-Jun-13 22:20 
QuestionHow to defeat God Pin
Bram van Kampen5-Jun-13 15:02
Bram van Kampen5-Jun-13 15:02 
AnswerRe: How to defeat God Pin
Dave Kreskowiak5-Jun-13 15:13
mveDave Kreskowiak5-Jun-13 15:13 
AnswerRe: How to defeat God Pin
Pete O'Hanlon5-Jun-13 19:23
mvePete O'Hanlon5-Jun-13 19:23 
AnswerRe: How to defeat God Pin
Richard MacCutchan5-Jun-13 21:14
mveRichard MacCutchan5-Jun-13 21:14 
GeneralRe: How to defeat God Pin
Bram van Kampen7-Jun-13 0:25
Bram van Kampen7-Jun-13 0:25 
GeneralRe: How to defeat God Pin
Richard MacCutchan7-Jun-13 1:02
mveRichard MacCutchan7-Jun-13 1:02 

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.