RE: Conversion from VT_DECIMAL TO VT_I8 failed



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
|

.



Relevant Pages

  • Web Developers - Happy Hearts And HDTV! - Lockergnome
    ... Certificate on your MSIIS Web server. ... getting data from a database is only half the problem. ... Zend recently started a series about building rock solid code in PHP. ... which provides bulk database conversion. ...
    (freebsd-questions)
  • Re: Converting database from Access 97 to 2003: problems
    ... Although the owner of the database had all the rights the conversion was not ... placed the Admin user in the Admins group (Admins group has Administrator ...
    (microsoft.public.access.conversion)
  • Re: MDW
    ... using the MDB at the same time. ... When Access 2003 enables the database, ... Multi-User Databases are databases which have an associated WIF (Workgroup ... that could complicate the conversion process. ...
    (microsoft.public.access.gettingstarted)
  • Converting from Access97 to Access 2002 -- OpenCurrentDatabase or OpenDatabase
    ... the routine opens an initialized converted database (i.e. one ... without any custom objects), then opens the Access97 database, exports the ... that doesn't seem to affect the conversion). ...
    (microsoft.public.access.conversion)
  • OpenCurrentDatabase or OpenDatabase - different versions of Access
    ... the routine opens an initialized converted database (i.e. one ... without any custom objects), then opens the Access97 database, exports the ... that doesn't seem to affect the conversion). ...
    (microsoft.public.access.modulesdaovba)

Quantcast