Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Conversion from VT_DECIMAL TO VT_I8 failed

41 views
Skip to first unread message

hfann

unread,
Jul 31, 2005, 10:33:12 PM7/31/05
to
Hi,

I have a C++ program that creates records in a MSDE2000a database. I use a
stored procedure to create the record and it returns an identity value. The
returned value is stored in a BIGINT output parameter.

CREATE PROCEDURE dbo.AddEntry
...,
@pEntryID BIGINT = NULL OUTPUT
AS
...

In C++ code:

_ParameterPtr Parm =
pCommand->CreateParameter(L"@pEntryID",adBigInt,adParamOutput,9);
pCommand->Parameters->Append(Parm);
pCommand->Execute(0,0,adCmdStoredProc);
...
__int64 iRecID = 0;
try {
_variant_t Val = Parm->Value;
iRecID = Val;
} catch(_com_error &e) {
_bstr_t sMsg = e.Description();
return -1;
}

The program runs fine on an English version of Windows XP. On a German
version of Windows 2000, the conversion (iRec = Val;) always fails with
0x80020008 COM error. In both cases, the database is created with an English
version of MSDE2000a.

Why does a BIGINT parameter becomes a VT_DECIMAL variant? Why does the
conversion failed? Did I code something wrong? What is the workaround?

Thanks,
--
Herbert
Fann Software
http://www.fannsoftware.com

Steven Cheng[MSFT]

unread,
Aug 1, 2005, 6:56:05 AM8/1/05
to
Hi Herbert,

Welcome to MSDN newsgroup.
Regarding on the Type Converting problem met in accessing database through
ado, based on the code you provided, here are some of our suggestion:

Since this is likely a environment specific problem, currently what we can
do is simply do some further tests. for the _variant_t , it has a
"ChangeType" function which can help explicitly cast the currently value in
the _variant_t instance into our specified type. I suggest you try using
this method to explicitly cast the returned value before assign it to the
_int64(long long type). Just as:

_variant_t Val = Parm->Value;

//call ChangeType here
iRecID = Val;

Please feel free to post here if there is any other findings. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: Conversion from VT_DECIMAL TO VT_I8 failed
| thread-index: AcWWQVzLUIfb1bp3TtKJY53jrBB/Dg==
| X-WBNR-Posting-Host: 70.28.142.201
| From: "=?Utf-8?B?aGZhbm4=?=" <hf...@nospam.nospam>
| Subject: Conversion from VT_DECIMAL TO VT_I8 failed
| Date: Sun, 31 Jul 2005 19:33:12 -0700
| Lines: 41
| Message-ID: <A83514C7-46BD-453E...@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.data.oledb
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.data.oledb:2665
| X-Tomcat-NG: microsoft.public.data.oledb

hfann

unread,
Aug 1, 2005, 2:57:15 PM8/1/05
to
Hi Steven,

I have tried

iRecID = (__int64)Val;

or

Val.ChangeType(VT_I8);
iRecID = Val;

Both failed on a fresh German Windows 2000 Pro with SP4 system.

Why does a BIGINT parameter becomes a VT_DECIMAL variant? Should it create a
VT_I8 variant in the first place?

Thanks,

--
Herbert
Fann Software
http://www.fannsoftware.com

Kevin Yu [MSFT]

unread,
Aug 2, 2005, 3:16:33 AM8/2/05
to
Hi Herbert,

Based on my research, this might be a known problem in earlier version of
MDAC. Since you're using Windows 2000 sp4, I suggest you apply MDAC 2.8
sp1. You can download it from the following link and select German in the
language selection.

http://www.microsoft.com/downloads/details.aspx?FamilyID=78cac895-efc2-4f8e-
a9e0-3a1afbd5922e&DisplayLang=en

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

hfann

unread,
Aug 2, 2005, 11:59:01 AM8/2/05
to
Hi,

After I installed a German version MDAC 2.8 SP1, the conversion still failed
with 0x80020008 error when I debuged it in VS.NET 2003.

Thanks,
--
Herbert
Fann Software
http://www.fannsoftware.com

Kevin Yu [MSFT]

unread,
Aug 3, 2005, 1:36:25 AM8/3/05
to
Hi Herbert,

In this case, I suggest you contact Microsoft PSS for this issue, since
they might have resource to test this issue. You can get the contact
information from the following link

http://support.microsoft.com/default.aspx?scid=fh;EN-US;OfferProPhone

0 new messages