Google Groups không còn hỗ trợ đăng ký sử dụng hoặc đăng nội dung mới trên Usenet. Bạn vẫn có thể xem nội dung cũ.

Conversion from VT_DECIMAL TO VT_I8 failed

41 lượt xem
Chuyển tới thư đầu tiên chưa đọc

hfann

chưa đọc,
22:33:12 31 thg 7, 200531/7/05
đến
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]

chưa đọc,
06:56:05 1 thg 8, 20051/8/05
đến
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

chưa đọc,
14:57:15 1 thg 8, 20051/8/05
đến
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]

chưa đọc,
03:16:33 2 thg 8, 20052/8/05
đến
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

chưa đọc,
11:59:01 2 thg 8, 20052/8/05
đến
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]

chưa đọc,
01:36:25 3 thg 8, 20053/8/05
đến
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 tin nhắn mới