🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
2 messages
2 total messages Started by Jenny Asplund Wed, 21 Jun 2000 00:00
In desperat need of help!
#1012
Author: Jenny Asplund
Date: Wed, 21 Jun 2000 00:00
47 lines
2192 bytes
Hi!
Don't know if this is the right newsgroup but here it goes.
I have a program with a database containing facts about music CD's.
In my program I have a ComboBox where I choose what to search for (e.g.
artist, track, albumtitle etc.) and a Edit-box where i enter word of
phrase to search for.
The c++ code looks like this:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if(ComboBox1->Text = ="Artist")
    {
        DBGrid1->DataSource=DataSource5;
        Query4->Close();
        AnsiString AName=(AnsiString)"AName";
        Query4->ParamByName(AName)->AsString=Edit1->Text;
        Query4->Open();
    }

And the SQL-statement in the Query-component looks like this:

SELECT DISTINCT Artist, Album, Release FROM Artist, Album, Track
WHERE Artist LIKE :AName
AND Artist.AID = Track.AID
AND Track.CDID = Album.CDID

The SQL-statement works with no errors but I have the need to search
with wildcards in order to for example serch by artist and for rage and
get Rage Against The Machine in the DBGrid. (I hope you understand what
I mean)
The problem is this, I don't know how to use wildcards. In Access97 that

I use for my database, I can use '*rage*' and in other databases they
use % instead of *. The problem is that it does not work in a Query with

SQL-statement and parameters. I've tried to write '*:AName*', '%:AName%'

and so on but it doesn't work.

Can anyone help me and tell me where and how to use wildcards? In
desperat need of help because this program has to be finished and handed

over to my teacher sunday the 25:th of june.

Tnx in advanced!

///Jenny Asplund, Linkoping Sweden
Re: In desperat need of help!
#1018
Author: Jan Karpisek
Date: Mon, 26 Jun 2000 00:00
22 lines
1369 bytes
Hi,
maybe too late, just to let you know that work around is:

Query4->ParamByName("AName")->AsString=Edit1->Text + "%";

for your query:

> SELECT DISTINCT Artist, Album, Release FROM Artist, Album, Track
> WHERE Artist LIKE :AName
> AND Artist.AID = Track.AID
> AND Track.CDID = Album.CDID

> The SQL-statement works with no errors but I have the need to search
> with wildcards in order to for example serch by artist and for rage and
> get Rage Against The Machine in the DBGrid. (I hope you understand what
> I mean)
> The problem is this, I don't know how to use wildcards. In Access97 that
>
> I use for my database, I can use '*rage*' and in other databases they
> use % instead of *. The problem is that it does not work in a Query with
>
> SQL-statement and parameters. I've tried to write '*:AName*', '%:AName%'
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads