Convert Variant to Char
Posted on 2000-03-31
I have created my own vb function called 'RunSPNoRecords.' It resides in an activeX DLL. The function's purpose is to execute a stored procedure and return no recordset. It's return value is the return value of the stored procedure. The function is being passed a variant array which contains the values for the stored procedure's parameters. I'm using the cmd.Refresh method to retrieve the name, datatype, direction, and size of each stored procedure parameter. This information is used to create a new command object. (using CreateParameter) The new command object is then executed and the return value is retrieved.
Everything works fine except that if the stored procedure contains a parameter of type 'Char' then I cannot assign the value of the parameter. The value that I want to assign is coming from the variant array. I'm trying to pass that value to the Value argument of the CreateParameter function. The error is:
ADODB.Parameter error '800a0d5d'
The application is using a value of the wrong type for the current operation.
If I change the data type of the stored procedure parameters to varchar then it works fine. That is not an option though.
Does anyone have a solution to this problem? Thank you for your help.