tcgoh Active Member Licensed User Longtime User Aug 27, 2012 #1 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.
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 Aug 27, 2012 #2 You can use a 'try-catch' block: Code: try lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") catch lblr.Text="0" end try Upvote 0
You can use a 'try-catch' block: Code: try lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") catch lblr.Text="0" end try
Informatix Expert Licensed User Longtime User Aug 27, 2012 #3 You can also use an object to test if null: Code: Dim SQLResult As Object SQLResult = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") if SQLResult = Null then lblr.Text = "" else lblr.Text = SQLResult end if Upvote 0
You can also use an object to test if null: Code: Dim SQLResult As Object SQLResult = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") if SQLResult = Null then lblr.Text = "" else lblr.Text = SQLResult end if
tcgoh Active Member Licensed User Longtime User Aug 27, 2012 #4 mc73 said: You can use a 'try-catch' block: Code: try lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") catch lblr.Text="0" end try Click to expand... 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'") Click to expand... Is there a way to return the text to " " blank ? or any other text instate of "Null"? Thanks Upvote 0
mc73 said: You can use a 'try-catch' block: Code: try lblr.Text = SQL1.ExecQuerySingleResult("select date from table where date = '30-08'") catch lblr.Text="0" end try Click to expand... 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'") Click to expand... Is there a way to return the text to " " blank ? or any other text instate of "Null"? Thanks
Informatix Expert Licensed User Longtime User Aug 27, 2012 #5 tcgoh said: Is there a way to return the text to " " blank ? or any other text instate of "Null"? Click to expand... The answer is in the previous posts. Read them carefully. Upvote 0
tcgoh said: Is there a way to return the text to " " blank ? or any other text instate of "Null"? Click to expand... The answer is in the previous posts. Read them carefully.
tcgoh Active Member Licensed User Longtime User Aug 27, 2012 #6 Informatix said: The answer is in the previous posts. Read them carefully. Click to expand... Thanks, but not using your code and I have found a work around. Upvote 0
Informatix said: The answer is in the previous posts. Read them carefully. Click to expand... Thanks, but not using your code and I have found a work around.