I have wrapper methods for database calls, so I can handle and more particularly log errors, and not have to pad out the main logic for every database call. So, for ExecuteSQL, I might have this:
dbexec (Extends dbh as sqlitedatabase, sql as string, ParamArray args as Variant) as Boolean
try
dbh.ExecuteSQL (sql, args)
Return True // Worked fine, just return
Catch e as DatabaseException
dblogargs (args) // Log argument values here
end try
.
What I want to do in dblogargs is to pick out the args which are integers, and log only those, so I might end up with a message in the log file something like:
arg0=27, arg3=5, arg4=7
(in this picture, I skip arg1 and arg2 because they are strings)
Where I’m getting into trouble is getting the type of each element of args, the ParamArray. If I look at VarType(arg) or arg.Type(), then each arg appears to be type 9 (Object). And if I have an arg that I know to be an integer, then something like:
Var i as Integer = arg.IntegerValue
just gives me a TypeMismatchException. How do I get at the integer that must be hidden in there somehow?
14 posts - 5 participants