VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Invoke line below produces an error relating to DBNULL value when there is no data in the SELECT string, i.e. WHERE clause. How can I prevent this error? I hope that I adequately described this.
Command1.CommandText = "SELECT SUM(fosterparent.spaces) FROM fosterparent
WHERE status2 = 'Approved' and county = 'LA'"
Invoke(Sub() Capacity = System.Convert.ToInt32(Command1.ExecuteScalar))
Probably the simplest solution is:
Command1.CommandText = "SELECT isnull(SUM(fosterparent.spaces), 0) FROM . . ."
Hi
Untested:
Invoke(Sub() Integer.TryParse(CommandText, Capacity))
This worked...thank you very much. 5 stars for you.
LesHay,
Your code did not work because VS saw TryParse and CommandText as undefined items.
But thanks for your suggestion.