RE: Conversion from VT_DECIMAL TO VT_I8 failed
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Mon, 01 Aug 2005 10:56:05 GMT
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=?=" <hfann@xxxxxxxxxxxxx>
| 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-A1D5-901BD1271104@xxxxxxxxxxxxx>
| 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
|
| 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
|
.
- Follow-Ups:
- RE: Conversion from VT_DECIMAL TO VT_I8 failed
- From: hfann
- RE: Conversion from VT_DECIMAL TO VT_I8 failed
- References:
- Conversion from VT_DECIMAL TO VT_I8 failed
- From: hfann
- Conversion from VT_DECIMAL TO VT_I8 failed
- Prev by Date: Conversion from VT_DECIMAL TO VT_I8 failed
- Next by Date: OLEDB Provider in C#
- Previous by thread: Conversion from VT_DECIMAL TO VT_I8 failed
- Next by thread: RE: Conversion from VT_DECIMAL TO VT_I8 failed
- Index(es):
Relevant Pages
|