Board index » cppbuilder » Re: Invalid Variant Operation

Re: Invalid Variant Operation


2003-07-03 07:52:53 AM
cppbuilder84
Wrong newsgroup. You have posted in the newsgroup for the old Borland C++
compiler but your question is about the C++ Builder compiler. Look for
newsgroups with the word 'cppbuilder' in the name. A list of newsgroups is
on Borland's newsgroups page:
info.borland.com/newsgroups
I wish I could tell you the solution but I've no idea what is wrong here :-(
. Ed
Quote
Rick Chronister wrote in message
news: XXXX@XXXXX.COM ...

I keep getting an "Invalid Variant Operation" on client's pc
running a program I created in BCB 6 that is executing an
update query on an XP computer. I ran the same program
on my XP computer and on an XP notebook and it runs fine.
Is there any .dll's I need to look at on the client's pc that may
be different/corrupted? Any other ideas?

P.S. I already tried uninstalling the application, deleting all files
in "Borland Shared", deleting any registry entries, rebooting,
then reinstalling to no avail.
 
 

Re:Re: Invalid Variant Operation

generate a MAP file., give them a new EXE copy.
when the error comes up. have them give you the
address location.
find that in the map file and a near location then you
will know what functions are failing to assign a Variant.
Rick Chronister wrote:
Quote
I keep getting an "Invalid Variant Operation" on a client's pc running a
program I created in BCB 6 that is executing an update query on an XP
computer. I ran the same program on my XP computer and on an XP
notebook and it runs fine. Is there any .dll's I need to look at on the
client's pc that may be different/corrupted? Any other ideas?

P.S. I already tried uninstalling the application, deleting all files in
"Borland Shared", deleting any registry entries, rebooting, then
reinstalling to no avail.

Thanks,
Rick Chronister
ACS- Fort Wayne, IN

Quote, "I will ask for no more and no less than what I earn."
--Ayn Rand
Atlas Shrugged (John Galt?)
 

Re:Re: Invalid Variant Operation

I have a stored procedure in SQL Server 2000 that I am calling from a D5
app.
The SP starts a transaction, updates various tables and then commits the
transaction.
When I am testing this with 2 client PC's calling this same SP at exactly
the same time, every now and again if the timimg is just right, one of the
PC's get a message saying 'Invalid Variant Operation' and the update is
rolled back. The updates on the other PC get committed fine.
This error will only ever occur in the above scenario so seems to be some
sort of contention problem.
Can anyone help me out with this?
Thanks for any advice.
Matthew
 

{smallsort}

Re:Re: Invalid Variant Operation

I have a stored procedure in SQL Server 2000 that I am calling from a D5
app.
The SP starts a transaction, updates various tables and then commits the
transaction.
When I am testing this with 2 client PC's calling this same SP at exactly
the same time, every now and again if the timimg is just right, one of the
PC's get a message saying 'Invalid Variant Operation' and the update is
rolled back. The updates on the other PC get committed fine.
This error will only ever occur in the above scenario so seems to be some
sort of contention problem.
Can anyone help me out with this?
Thanks for any advice.
Matthew
 

Re:Re: Invalid Variant Operation

I have a stored procedure in SQL Server 2000 that I am calling from a D5
app.
The SP starts a transaction, updates various tables and then commits the
transaction.
When I am testing this with 2 client PC's calling this same SP at exactly
the same time, every now and again if the timimg is just right, one of the
PC's get a message saying 'Invalid Variant Operation' and the update is
rolled back. The updates on the other PC get committed fine.
This error will only ever occur in the above scenario so seems to be some
sort of contention problem.
Can anyone help me out with this?
Thanks for any advice.
Matthew
 

Re:Re: Invalid Variant Operation

Hi Brain,
Thanks for your help. You were correct, I was trying to access the return
parameter as an integer.
I have removed that logic and I am now receiving a message saying that a
deadlock occurred and the transaction was rolled back. Could you please help
with the best way to check for this so I could re-try the stored procedure
without the user having to know?
Regards,
Matthew
"Brian Bushay TeamB" < XXXX@XXXXX.COM >wrote in message
Quote

>I have a stored procedure in SQL Server 2000 that I am calling from a D5
>app.
>
>The SP starts a transaction, updates various tables and then commits the
>transaction.
>
>When I am testing this with 2 client PC's calling this same SP at exactly
>the same time, every now and again if the timimg is just right, one of the
>PC's get a message saying 'Invalid Variant Operation' and the update is
>rolled back. The updates on the other PC get committed fine.
>
>This error will only ever occur in the above scenario so seems to be some
>sort of contention problem.
>
>Can anyone help me out with this?

Are you doing anything with Parameters returned by the stored procedure?
If you are I would look at something in your code happening if the
return
parameter is null. The look for contention issues in your stored proc
that
might cause the return parameter not to be set


--
Brian Bushay (TeamB)
XXXX@XXXXX.COM
 

Re:Re: Invalid Variant Operation

Matthew Pascoe wrote:
Quote
Can anyone help me out with this?
IME this error message commonly occurs when you assign
a NULL value from a field to a variable (like a string).
--
jc
Remove the -not from email
 

Re:Re: Invalid Variant Operation

Hi Brian,
Many thanks, you have solved my problems yet again.
The code you suggested is working perfectly.
Regards,
Matthew
"Brian Bushay TeamB" < XXXX@XXXXX.COM >wrote in message
Quote

>Thanks for your help. You were correct, I was trying to access the return
>parameter as an integer.
>
>I have removed that logic and I am now receiving a message saying that a
>deadlock occurred and the transaction was rolled back. Could you please
>help
>with the best way to check for this so I could re-try the stored procedure
>without the user having to know?

Put The execution inside a For loop so you can execute it multiple times
then Execute your storedProcedure inside a Try/Except block.
After the Execute use Break to exit the for loop

In the Except section check the TadoConnection.Errors collection for the
error
generated by a deadlock

For i:=0 To ADOConnection.Errors.Count-1 Do Begin

//you can look at
ADOConnection.Errors[i].Source;
ADOConnection.Errors[i].Description ;
ADOConnection.Errors[i].SQLState;
ADOConnection.Errors[i].number;
ADOConnection.Errors[i].nativeError;

End;

If the error isn't from a deadlock Raise the error again to get out of the
for
loop.


Also note that the most common reason for deadlocks is code that allows
user
interaction with the application while a transaction is in progress.



--
Brian Bushay (TeamB)
XXXX@XXXXX.COM
 

Re:Re: Invalid Variant Operation

Hi Brian,
Just a quick question on the return paramter bing null.
I am trying to figure out how to check for a null value so I don't create an
error.
The only way I seem to be able to access the value is
'proc1.Parameters.ParamByName('@RETURN_VALUE').Value'
It won't let me use AsInteger, AsString, or the IsNull option instead of the
'Value' property?
Thanks & Regards,
Matthew
"Matthew Pascoe" < XXXX@XXXXX.COM >wrote in message
Quote
Hi Brian,

Many thanks, you have solved my problems yet again.

The code you suggested is working perfectly.

Regards,
Matthew


"Brian Bushay TeamB" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>
>>Thanks for your help. You were correct, I was trying to access the return
>>parameter as an integer.
>>
>>I have removed that logic and I am now receiving a message saying that a
>>deadlock occurred and the transaction was rolled back. Could you please
>>help
>>with the best way to check for this so I could re-try the stored
>>procedure
>>without the user having to know?
>
>Put The execution inside a For loop so you can execute it multiple times
>then Execute your storedProcedure inside a Try/Except block.
>After the Execute use Break to exit the for loop
>
>In the Except section check the TadoConnection.Errors collection for the
>error
>generated by a deadlock
>
>For i:=0 To ADOConnection.Errors.Count-1 Do Begin
>
>//you can look at
>ADOConnection.Errors[i].Source;
>ADOConnection.Errors[i].Description ;
>ADOConnection.Errors[i].SQLState;
>ADOConnection.Errors[i].number;
>ADOConnection.Errors[i].nativeError;
>
>End;
>
>If the error isn't from a deadlock Raise the error again to get out of
>the for
>loop.
>
>
>Also note that the most common reason for deadlocks is code that allows
>user
>interaction with the application while a transaction is in progress.
>
>
>
>--
>Brian Bushay (TeamB)
> XXXX@XXXXX.COM


 

Re:Re: Invalid Variant Operation

Hi Jeremy,
Thanks, you were correct. The return value from the SP was null.
Regards,
Matthew
"Jeremy Collins" < XXXX@XXXXX.COM >wrote in message
Quote
Matthew Pascoe wrote:

>Can anyone help me out with this?

IME this error message commonly occurs when you assign
a NULL value from a field to a variable (like a string).

--
jc

Remove the -not from email
 

Re:Re: Invalid Variant Operation

Matthew Pascoe wrote:
Quote
Hi Jeremy,

Thanks, you were correct. The return value from the SP was null.
If you're not sure whether a result is going to be NULL,
it's sometimes a good idea to wrap the result (for strings)
in VarToStr(), which won't raise an exception but returns
an empty string instead. It's a bit neater than wrapping
everything in
if VarIsNull(...) then
...
statements.
For integers and floats etc you can roll your own versions,
for example I have two overloaded funtions like this:
function VarToFloat(Value : Variant) : Extended;
begin
Result := VarToFloat(Value, 0);
end;
function VarToFloat(Value : Variant; Default : Extended) : Extended;
begin
if VarIsNull(Value) then
Result := Default
else
Result := Value;
end;
But you have to be careful, since a "default" value in place of
a NULL number is not always appropriate.
--
jc
Remove the -not from email
 

Re:Re: Invalid Variant Operation

I use:
If VarIsNull(proc1.Parameters.ParamByName('@RETURN_VALUE').Value) then
...
just add Variants to your uses if not already there.
hth,
brian
 

Re:Re: Invalid Variant Operation

Hi Brian,
Thanks, thats what I was looking for.
Sorry for the delay in replying, I have been away.
Matthew
"Brian Hollister" <bhollisterATfuturaintlDOTcom>wrote in message
Quote
I use:

If VarIsNull(proc1.Parameters.ParamByName('@RETURN_VALUE').Value) then
...

just add Variants to your uses if not already there.

hth,

brian



 

Re:Re: Invalid Variant Operation

Hi Brian,
Sorry for the delay in replying, I have been away. Thanks again for your
help.
I am having quite a few problems with timeouts and deadlocks.
I have been doing some reading about locking but am finding it hard to
understand exactly what will cause a lock and what does not cause a lock.
Can you suggest a good resource? (I am using SQL Server 2000 and D5 with
ADO)
A couple of other stupid questions:
1) Can a select statement cause a lock on the records that it reads?
2) I have a SP that makes updates to several tables. It seems to be able to
cause a deadlock when 2 users run it at the same time even though they would
definitely not be trying to update the same records (same tables but not
same records). What sorts of things do I need to look out for?
3) Cursors - I have read they are evil and to be avoided. However, our
application lets the user set up 'rules' that each contains steps the system
should follow when processing an order, etc. We need to load the rule and
process each step one after the other. Is there a better way than a cursor
or are cursors justified in this case?
Thanks in advance for any help.
Regards,
Matthew
"Brian Bushay TeamB" < XXXX@XXXXX.COM >wrote in message
Quote

>Just a quick question on the return paramter bing null.
>
>I am trying to figure out how to check for a null value so I don't create
>an
>error.
>
>The only way I seem to be able to access the value is
>'proc1.Parameters.ParamByName('@RETURN_VALUE').Value'
>
>It won't let me use AsInteger, AsString, or the IsNull option instead of
>the
>'Value' property?
You already got the correct answer from Brian Holister on this one.
I just want to add that you really should try to figure out why you are
getting
the deadlock and if there is another way to write your stored procedure to
avoid
it. Deadlocks use up a lot of resources and if you are adding more uses
you are
likely to get them more frequently.

Brian
--
Brian Bushay (TeamB)
XXXX@XXXXX.COM
 

Re:Re: Invalid Variant Operation

Brian,
Thanks once again. I will implement your suggestions and see how it goes.
I do have a couple of other questions that have just popped up:
1) In D5 does setting the command timeout on the ADOConnection component
work or does it have to be done in the ADOCommand component?
2) In a SP, does a lock timeout cause the SP to exit without completing the
rest of the statements? It is my understanding that a deadlock will exit the
SP immediately, was wondering if lock timeouts are the same?
Matthew
"Brian Bushay TeamB" < XXXX@XXXXX.COM >wrote in message
Quote
>
>1) Can a select statement cause a lock on the records that it reads?
Depending on the isolation level you have set there are various levels of
locks
to keep the records that are being read from being changed by another
process


>2) I have a SP that makes updates to several tables. It seems to be able
>to
>cause a deadlock when 2 users run it at the same time even though they
>would
>definitely not be trying to update the same records (same tables but not
>same records). What sorts of things do I need to look out for?
Do what ever you can to optimize the Updates. You can also look a having
some
of the processing use temporary tables if it will reduce the time that it
takes
to make updates to regular tables or pushes the update of regular tables
to the
end of the stored procedure.


>3) Cursors - I have read they are evil and to be avoided. However, our
>application lets the user set up 'rules' that each contains steps the
>system
>should follow when processing an order, etc. We need to load the rule and
>process each step one after the other. Is there a better way than a cursor
>or are cursors justified in this case?
You may be able to have the rules call different stored procedures that do
update queries instead of using cursors.
--
Brian Bushay (TeamB)
XXXX@XXXXX.COM