I have created a dictionary with key value mappings, and an empty array (e.g. MyArray) as variant.
I believe all values in dictionaries are stored as Variant.
I therefore check the VarType of each value e.g. MyDict.Value(key).
If VarType is 3 (Integer), I add to the array as follows: MyArray.Add(MyDict.Value(key).IntegerValue)
If it is 8 (String), I add to the array as follows: MyArray.Add(MyDict.Value(key).StringValue)
Then I pass MyArray into ExecuteSQL as follows: MyDatabase.ExecuteSQL(sql, MyArray)
However, when trying to run the query, the web app session interrupt message appears so it seems like the database can’t parse the data. I think it has something to do with the StringValue stored in MyArray. If I test it by storing a random String in place of MyArray.Add(MyDict.Value(key).StringValue) e.g. MyArray.Add("testString"), the query runs perfectly fine.
First, since you are working with Variants in both the array and Dictionary, the casting is unnecessary unless you are trying to cast to something else. For example, if the Variant holds an Integer but you want to return it as a String.
What is the query, and code, you are attempting, and against what kind of database?
where sqlCols is a comma-separated string of all columns and sqlValues is comma-separated string all corresponding values
sqlValues contains ‘?’ for every value that is passed in as a parameter in ExecuteSQL
it was implemented in a loop so takes almost 50 different values.
I have looked through each value in the dictionary and they are all strings. Some are empty strings while some others are numeric values casted as string e.g. ‘54232’
Thanks - looks like we have found the issue.
Empty string breaks it.
So I did the following
Var testString As String
testString = ""
and inside my loop, I add it to my array. MyArray.Add(testString)
It fails when trying to ExecuteSQL. By simply replacing empty string in testString above with a non-empty string, it works. I take it that this is a bug?