G
Guest
Hello,
'Shmo' is a unique word in tbl1. If it exists in tbl1, then I write it to
the console.
cmd.commandType = CommandType.Text
cmd.CommandText = "Select fldx From tbl1 Where fldx = 'Shmo'"
console.writeline(cmd.ExecuteScalar.ToString)
If 'Shmo' does not exist in tbl1 - I get a nullreferenceException. I deal
with this exception in a try-catch-finally block. My question is if there is
a way to deal with the non-existence of 'Shmo' besides try-catch.
I tried
if cmd.executeScalar.ToString.Length > 0 Then console.writeline...
but I still got an exception when there was no 'Shmo' to be found. Is there
a better way to deal with this than just Try-Catch?
Thanks,
Rich
'Shmo' is a unique word in tbl1. If it exists in tbl1, then I write it to
the console.
cmd.commandType = CommandType.Text
cmd.CommandText = "Select fldx From tbl1 Where fldx = 'Shmo'"
console.writeline(cmd.ExecuteScalar.ToString)
If 'Shmo' does not exist in tbl1 - I get a nullreferenceException. I deal
with this exception in a try-catch-finally block. My question is if there is
a way to deal with the non-existence of 'Shmo' besides try-catch.
I tried
if cmd.executeScalar.ToString.Length > 0 Then console.writeline...
but I still got an exception when there was no 'Shmo' to be found. Is there
a better way to deal with this than just Try-Catch?
Thanks,
Rich