2
Answers

access + c#

ilhami caliskan

ilhami caliskan

10y
1.1k
1
Hello All,
can anybody tell me what is wrong with this code for c#?
tmp.Mobile2 = reader.IsDBNull(19)? reader.GetString(19) : ""; 
I'm reading datas from accessDB, want to write -> if value = null (no entered data) then return ""  
Or any other solution? 
Answers (2)
2
Vulpes

Vulpes

NA 96k 2.6m 10y
You have the last two arguments of the ternary operator the wrong way around.

It should be:

tmp.Mobile2 = reader.IsDBNull(19) ? "" : reader.GetString(19); 

Accepted
0
Akhil Mittal

Akhil Mittal

NA 26.3k 7.8m 10y
Its Vice Versa, tmp.Mobile2 = reader.IsDBNull(19) ? "" : reader.GetString(19);