?
Solved

Searching a Dbmemo Field in Delphi 3

Posted on 1998-12-10
7
Medium Priority
?
627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 7

Accepted Solution

by:
ahalya earned 60 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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