Solved

Searching a Dbmemo Field in Delphi 3

Posted on 1998-12-10
7
620 Views
Last Modified: 2012-06-27
Is there a component to search for text in Dbmemo field and to check whether the memo field has no text.
Code will also do(in case of no component)
Regards
venks
0
Comment
Question by:venks
  • 4
  • 3
7 Comments
 
LVL 7

Accepted Solution

by:
ahalya earned 20 total points
ID: 1350345
Here's how i search a Memo field in my code.  The function "GetBlobAsString" returns the contents of the memo as ANSIString. Then i use the regular string searching functions.

function TSearchForm.GetBlobAsString(Blob:TBlobField): string;

var
   BlobStream: TBlobStream;
   a: array [0..8192] of Char;
   i:longint;

begin
Result:='';
BlobStream := TBlobStream.Create(Blob, bmRead);
   try
   i := BlobStream.Size;
  FillChar(a, i, #0);
   BlobStream.Read(a, i);
   finally
   BlobStream.Free;
  end;
a[i] := #0; {set the last character as null}
Result:=StrPas(a);
end;

--------------
and in my code , i do a
     FieldValue := GetBlobAsString(TMemoField(Table1.FieldByName('About')));
     FieldValue := lowercase(FieldValue);
     Match := (pos(KeyWd, FieldValue) <> 0 );
=================  
0
 
LVL 1

Author Comment

by:venks
ID: 1350346
Dear ahalya
Does your code search for mullti line text in the dbmemo.Can you geve code for a dbmemo rather than a memo field

Regards
venks

0
 
LVL 7

Expert Comment

by:ahalya
ID: 1350347
Hi Venks,

i haven't had a chance to use a "DBMemo" yet :-)  

But inside the "GetBlobAsString" you have a lot of choice, including using TStrings & pchar. i'd guess that after reading the BlobStream, you'd a lot better off by using TStrings, if you want to seperate the lines.

Ciao,
A.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:venks
ID: 1350348
Dear ahalya
I tried to use your code .But i was not sure how to use your function.Is it possible to give a complete example for callingthe Getblobasstring function for searching for data.
Regards
venks
0
 
LVL 7

Expert Comment

by:ahalya
ID: 1350349
procedure TForm1.Button1Click(Sender: TObject);

var s : String;

begin;
//search for the occurence of 'venks'  in the Field 'About'
//About is a  Memo type Field in Table 1.
//you code will have
//     DBMemo1.DataField := 'Memo'
//     DBMemo1.DataSource := DataSource1;
//     DataSource1.Dataset := Table1;


 s :=  GetBlobAsString(TMemoField(Table1.FieldByName('About')));
//you can also use
// s :=  GetBlobAsString(TMemoField(Table1.FieldByName(DBMemo1.DataFiled)));

 s := lowercase(s);
 if  (pos('venks'  FieldValue) <> 0 ) then FoundMatch
 else   Match NotFound.

end;

0
 
LVL 1

Author Comment

by:venks
ID: 1350350
Dear Ahalya
Thanks
venks
0
 
LVL 7

Expert Comment

by:ahalya
ID: 1350351
btw, Venks you gave a "B" to my answer.

To what answer would you have given an "A" ?  -just wondering.

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question