🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #809

Re: Use of ADO Recordset

#809
From: Viatcheslav V. Vassiliev
Date: Sun, 08 May 2005 17:00
63 lines
2999 bytes
OleVariant v =
ADODataSet1->Recordset->Fields->Item[WideString("au_id")]->Value;


Remove OLECHECK (compile-time) in C++ Builder 6 (not needed in earlier):

#include <comobj.hpp>

namespace System
{
 void __fastcall CheckSafecallResult(HRESULT hr)
 {
  OleCheck(hr);
 }
}

When converting OleVariant, use (WideString)v or similar, you may have
OleVariant with other type that VT_BSTR and use .bstr() may have
unpredictable results - for example, you may get OleVariant with type
VT_NULL.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Bas Groeneveld" <nospam@nospam.com.au> �������/�������� � �������� 
���������: news:427b1331@newsgroups.borland.com...
>> In type library Item is property, and GetItem, get_Item and/or [] depends
> on
>> program that imports type library. [] are imported, if I am not wrong, by
>> C++ Builder 6, but not earlier.
>
> Interesting I am using C++Builder 6 but definitely don't appear to have []
> available.
>
>>
>> >            wstUser =
>> > adoRS->Fields->get_Item(Variant(1))->get_Value().bstrVal;
>>
>> try
>>
>> adoRS->Fields->getItem(WideString("User"))->get_Value();
>
> wstUser = 
> adoRS->Fields->get_Item(WideString("User"))->get_Value().bstrVal;
> - generates a compiler error [C++ Error] fRxWorks.cpp(134): E2285 Could 
> not
> find a match for 'Fields15::get_Item(WideString)'
>
> wstUser = adoRS->Fields->get_Item(Variant("User"))->get_Value().bstrVal;
> - compiles but generates a runtime error reported by OLECHECK
>
> wstUser = adoRS->Fields->get_Item(Variant(1))->get_Value().bstrVal;
> - compiles and runs ok
>
> Cheers
> Bas
>
> 
Technical Details
Message-ID: <427e45b6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <42787b1f$1@newsgroups.borland.com> <42789e2f$1@newsgroups.borland.com> <42796494@newsgroups.borland.com> <4279b874@newsgroups.borland.com> <427b1331@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,6b79b4524634c0b2
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <42787b1f$1@newsgroups.borland.com> <42789e2f$1@newsgroups.borland.com> <42796494@newsgroups.borland.com> <4279b874@newsgroups.borland.com> <427b1331@newsgroups.borland.com>
Subject: Re: Use of ADO Recordset
Date: Sun, 8 May 2005 21:00:38 +0400
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 85.93.138.132
Message-ID: <427e45b6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1115571638 85.93.138.132 (8 May 2005 10:00:38 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail