🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Convert TADOTable::Lookup result to AnsiString when the result field is empty

#1993
From: Daniel Stevenson
Date: Mon, 08 Dec 2003 02:23
32 lines
2159 bytes
the Current method for converting a Lookup result into an AnsiString is to
use the following code

(Long Version:)
Variant Result = tblADOTable->Lookup("Field1", iValue, "ReturnField");
if(Result.Type() != varNull && Result.Type() != varEmpty)
  AnsiString asString = Result.AsType(varString);
else
  AnsiStirng asString = "";


This is somewhat tedious especially if you are performing lookups on
multiple tables.
I have in the past used a TKADaoTable which was able to perform exactly the
same result but using the following single line:

(Short Version:)
AnsiString Result = tblKADOTable->Lookup("Field1", iValue,
"ReturnField").VOleStr;

This would return with either a blank ("") Result if the record's
ResultField was blank or it would return the value held within the
ResultField.


if I use the same code (ShortVersion) on a TADOTable, if the ResultField was
empty, the Lookup result would return random crap.  Is there a way of
ensuring the return value of a Lookup will return valid information or NO
information at all if the field is empty WITHOUT having to resort to using
the Long Version.

Thanks
Technical Details
Message-ID: <3fd3e0b6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,d2522f9ece01c5e0,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-12-07 18:39:17 PST
From: "Daniel Stevenson" <d.stevenson@ocreage.com.au>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Convert TADOTable::Lookup result to AnsiString when the result field is empty
Date: Mon, 8 Dec 2003 13:23:57 +1100
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 202.174.228.150
Message-ID: <3fd3e0b6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070850230 202.174.228.150 (7 Dec 2003 18:23:50 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail