BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DBEdit - Ability to restrict a character?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Kimberly Mills
Guest





PostPosted: Wed Aug 06, 2003 8:29 pm    Post subject: DBEdit - Ability to restrict a character? Reply with quote



Hi,

I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?

The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).

Any help is always greatly appreciated.

Kim

procedure TSetupExtOrgCourseMappingForm.DisplayExtOrgCredits;
begin
With ExtOrgCreditsQuery do begin
If Active then Close;
With SQL do begin
Clear;
Add ('Select credit_hrs ');
Add ('From ext_org_course_catalog ' );
Add ('Where master_Catalog_id = ''' + edtMasterCatalogID.Text + '''
and ');
Add ('ext_org_dept_cd = ''' + cbExtOrgDept.Text + ''' and ');
Add ('ext_org_course_cd = ''' + cbExtOrgCourse.Text + ''' and ');
Add ('ext_org_course_title = ''' + cbTitle.Text + ''' and ');
Add ('eff_status = ''A'' ');
Add ('Order by effdt desc ');
end;
open;
edtExtOrgCredits.text := FieldByName('credit_hrs').AsString;
close;
end;
end;


Back to top
Ryan Mills
Guest





PostPosted: Wed Aug 06, 2003 10:37 pm    Post subject: Re: DBEdit - Ability to restrict a character? Reply with quote



Quote:
I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?

The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).

Any help is always greatly appreciated.

Try using the function ansiquotestr. It would look something like this....

Add ('Where master_Catalog_id = ' + AnsiQuotesStr(edtMasterCatalogID.Text, ''') + ' and ');

Ryan

Back to top
Pomme-granite
Guest





PostPosted: Thu Aug 07, 2003 11:36 am    Post subject: Re: DBEdit - Ability to restrict a character? Reply with quote



If you created the query statically at designtime (rather than build
in your code) and added persistent fields, then it is easy :

ExtOrgCreditsQueryYOURFIELD.ValidChars :=
ExtOrgCreditsQueryYOURFIELD.ValidChars - [''''];

Paul Scott

On Wed, 6 Aug 2003 15:29:24 -0500, "Kimberly Mills"
<kimmills (AT) indiana (DOT) edu> wrote:

Quote:
Hi,

I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this possible?

The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in the
following code).

Any help is always greatly appreciated.

Kim

procedure TSetupExtOrgCourseMappingForm.DisplayExtOrgCredits;
begin
With ExtOrgCreditsQuery do begin
If Active then Close;
With SQL do begin
Clear;
Add ('Select credit_hrs ');
Add ('From ext_org_course_catalog ' );
Add ('Where master_Catalog_id = ''' + edtMasterCatalogID.Text + '''
and ');
Add ('ext_org_dept_cd = ''' + cbExtOrgDept.Text + ''' and ');
Add ('ext_org_course_cd = ''' + cbExtOrgCourse.Text + ''' and ');
Add ('ext_org_course_title = ''' + cbTitle.Text + ''' and ');
Add ('eff_status = ''A'' ');
Add ('Order by effdt desc ');
end;
open;
edtExtOrgCredits.text := FieldByName('credit_hrs').AsString;
close;
end;
end;



Back to top
Kimberly Mills
Guest





PostPosted: Fri Aug 08, 2003 2:46 pm    Post subject: Re: DBEdit - Ability to restrict a character? Reply with quote

Hi Ryan,

Your awesome!! This worked like a charm!! Thanks so much for your help!

Kim Mills

<Ryan Mills> wrote

Quote:
I have a dbedit box and a corresponding nav bar. I would like to restrict
users from entering single quotes into a particular field. Is this
possible?

The reason I ask is because the field is later user in a select query and
the query bombs if the field has a quote. (It terminates the string in
the
following code).

Any help is always greatly appreciated.

Try using the function ansiquotestr. It would look something like
this....

Add ('Where master_Catalog_id = ' + AnsiQuotesStr(edtMasterCatalogID.Text,
''') + ' and ');

Ryan



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.