Try
Dim count As Int
If txtPassword.Text = "" Then
count = Main.gSQL.ExecQuerySingleResult2($"SELECT count(*) FROM Account WHERE UserName = ? AND (Password = NULL OR Password ="")"$, Array(cmbUserName.Value))
Else
count = Main.gSQL.ExecQuerySingleResult2("SELECT count(*) FROM Account WHERE UserName = ? AND Password = ?", Array(cmbUserName.Value, txtPassword.Text))
End If
If count > 0 Then
Log("success")
Else
Log("failed")
End If
Notes:
1) Untested code and SQL. May need slight modification to actually run
2) If you just check for NULL passwords and not "" passwords, you're results will not be as expected, since technically, in your case a NULL password and "" password should produce the same results. See point #3
3) SQL Nulls sucks unless you are 100% consistent. Even then, they suck
4) Java Nulls suck
5) Nulls just plain suck. See
https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/
6) String Nulls are not what you expect them to be. You expect a Null string object, but B4J gives a a String with Null value. I have seen cases were external libs return Null string objects, and then things really get complicated in the whole Null checking. Therefore heed
@Erel's advice: Avoid Null Strings