Return Null on ExecQuerySingleResult

tcgoh

Active Member
Licensed User
Longtime User
Hi,

How can I return a Null or "0" into a edittext box with ExecQuerySingleResult, I get a error with this code.

lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'")

The textbox will return a value when the Query result can match a value.

I would like to display a zero or blank in the textbox when No matching result was found.

Thanks for any help.
 

mc73

Well-Known Member
Licensed User
Longtime User
You can use a 'try-catch' block:
B4X:
try
lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'")
catch
lblr.Text="0"
end try
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
You can use a 'try-catch' block:
B4X:
try
lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'")
catch
lblr.Text="0"
end try

Thanks. I found out that it will return "Null" if I follow up with another statement which I intended the code to be.

lblr.Text = SQL1.ExecQuerySingleResult("select TIME from table where dep = '27-08'")& " " & SQL1.ExecQuerySingleResult("select TIME from table where dep = '30-08'")

Is there a way to return the text to " " blank ? or any other text instate of "Null"?

Thanks
 
Upvote 0
Top