Bah, vbscript.
I'm trying to figure out how to get this statement to work:
if (not rsObject("columnNameThatDoesntExist") is nothing) then
' do some stuff
end if
' else do nothin
Where rsObject is a RecordSet and columnNameThatDoesntExist is ... well you know. I'm looking for something like rsObject.Columns.Contains(string). But of course can't find it.
Edit: Looks like looping rsObject.Fields is an option, is that the only way to do this?
I am sure you have your reasons, but if you don't know what fields you are calling back from your database, you could always use On Error Resume Next and On Error Goto 0 to ignore the tossed error. Seems like a bad way to me, but it would work
blnItWasntThere = True
On Error Resume Next
If (rsObject("columnNameThatDoesntExist") <> "") Then
blnItWasntThere = False
...
...
...
End If
On Error Goto 0
If blnItWasntThere Then
'handle this error'
End If
But with that said, I think you would be more worried about the mystery recordset you are getting back.
Or make your own function
Function ColumnExists(objRS, Column)
Dim blnOutput, x
blnOutput = True
On Error Resume Next
x = objRS(Column)
If err.Number <> 0 Then blnOutput = False
On Error Goto 0
ColumnExists = blnOutput
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With