Looking up value without form 
Author Message
 Looking up value without form

Hello,

In D1, what would be the easiest way to have a function look up some database
stuff in a source file that has no accompanying form? This is just a unit with
some global variables and functions, and I like to have it contain a function
FullDescriptionOfABozoInOurDatabase(BozoID: LongInt): String

Thanks in advance,
Jan

-----------------------------------------------------------------------

P.O. Box 697              2300 RA  Leiden            The Netherlands
-----------------------------------------------------------------------
** Specialists in multimedia software for education and presentation **
-----------------------------------------------------------------------
Usage of this email address for commercial purposes costs US$ 50 per
message. By using this email address you agree to this condition.
-----------------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Looking up value without form

Hi Jan,

Something along the following lines?

function FullDescriptionOfABozoInOurDatabase(BozoID: LongInt): String;
begin
        Result := '';
        with TTable.Create do try
                Database := '<Your Alias Name>';
                TableName := '<Your Bozo Table Name>';
                IndexName := ''; {Blank for primary index, etc...}

                Open;

                if FindKey([BozoID]) then begin
                        Result := FieldByName('<Field you want to return>').AsString;
                end;

                Close;
        finally
                Free;
        end;
end;

HTH,
--
Conor
   (conor at crannburn dot com
    Remove garbage from email address to activate)



Quote:
> Hello,

> In D1, what would be the easiest way to have a function look up some
database
> stuff in a source file that has no accompanying form? This is just a unit
with
> some global variables and functions, and I like to have it contain a
function
> FullDescriptionOfABozoInOurDatabase(BozoID: LongInt): String

> Thanks in advance,
> Jan

> -----------------------------------------------------------------------

> P.O. Box 697              2300 RA  Leiden            The Netherlands
> -----------------------------------------------------------------------
> ** Specialists in multimedia software for education and presentation **
> -----------------------------------------------------------------------
> Usage of this email address for commercial purposes costs US$ 50 per
> message. By using this email address you agree to this condition.
> -----------------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Looking up value without form

Just a general comment about the usefulness of Delphi for database
applications...

The delphi approach ties the database too closely to the database files.  Its
great to be able to plop a field on a form and have it go to a database record.
 Its terrible if you ever need to extend your applications in directions
slightly different from your original expectation.  This posting is an example.
 I recently worked on a major project for a BIG company done in VB.  The same
problem happens there...... its so easy to tie a database record to the UI that
people never expected, or planned for, the eventuality that they would need to
access the database directly.  They couldn't get a database record without
LOADING UP THE USER INTERFACE.  This is pretty pathetic........

So, be careful about using those database vcl's without being absolutely sure
you've got clean access into the data some other way....
Brad

Quote:
>Subject: Re: Looking up value without form

>Date: Tue, Feb 10, 1998 04:41 EST

>Hi Jan,

>Something along the following lines?

>function FullDescriptionOfABozoInOurDatabase(BozoID: LongInt): String;
>begin
>    Result := '';
>    with TTable.Create do try
>            Database := '<Your Alias Name>';
>            TableName := '<Your Bozo Table Name>';
>            IndexName := ''; {Blank for primary index, etc...}

>            Open;

>            if FindKey([BozoID]) then begin
>                    Result := FieldByName('<Field you want to
return>').AsString;
>            end;

>            Close;
>    finally
>            Free;
>    end;
>end;

>HTH,
>--
>Conor
>   (conor at crannburn dot com
>    Remove garbage from email address to activate)



>> Hello,

>> In D1, what would be the easiest way to have a function look up some
>database
>> stuff in a source file that has no accompanying form? This is just a unit
>with
>> some global variables and functions, and I like to have it contain a
>function
>> FullDescriptionOfABozoInOurDatabase(BozoID: LongInt): String

>> Thanks in advance,
>> Jan

>> -----------------------------------------------------------------------

>> P.O. Box 697              2300 RA  Leiden            The Netherlands
>> -----------------------------------------------------------------------
>> ** Specialists in multimedia software for education and presentation **
>> -----------------------------------------------------------------------
>> Usage of this email address for commercial purposes costs US$ 50 per
>> message. By using this email address you agree to this condition.
>> -----------------------------------------------------------------------

BEVERNON


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ** Can I close the prior form without close second form ?**

2. Putting a form in a form without MDI

3. Absolute value without jumping (Was: Re: fast line routine continued)

4. Can I use TTable without a Form?

5. Accessing Databases without Forms?!

6. DELPHI WITHOUT FORMS???

7. Looking for a way to create DB's without BDE

8. Problems Accessing Table Without GUI Form

9. Can you access DB component without a form

10. Newcomer to Delphi - Retrieving data from tables without having to use form

11. Window creation in generic windows app compiled in Delphi (without forms etc)

12. TTable...instantiating without a form

 

 
Powered by phpBB® Forum Software