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 

Trying to use TMemo.Lines with TADOQuery.Sql (in Delphi2006)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Patrick
Guest





PostPosted: Fri Oct 13, 2006 7:57 pm    Post subject: Trying to use TMemo.Lines with TADOQuery.Sql (in Delphi2006) Reply with quote



In Delphi5 I am able to input an Sql select statement in a TMemo field, then
add the memo.Lines to the (TADOQuery) Sql string, and execute it:

if (memo.Lines.Count > 0) then begin
with qryTable do begin
Close;
Sql := memo.Lines;
ExecSql;
Open;
end;
end;

With Delphi2006 I get the error: [Pascal Error]: E2010 Incompatible types:
'TWideStrings' and 'TStrings'.

How can I (easily) do this in Delphi2006?

TIA--patrick
Back to top
Kevin Frevert
Guest





PostPosted: Fri Oct 13, 2006 11:14 pm    Post subject: Re: Trying to use TMemo.Lines with TADOQuery.Sql (in Delphi2 Reply with quote



"Patrick" <pdohogne (AT) majorcustomcable (DOT) com> wrote in message
news:452fa958$1 (AT) newsgroups (DOT) borland.com...
Quote:
Sql := memo.Lines;

With Delphi2006 I get the error: [Pascal Error]: E2010 Incompatible types:
'TWideStrings' and 'TStrings'.

How can I (easily) do this in Delphi2006?

Sql.Text := Memo.Lines.Text;

Or wrap the opening of the query into a function/procedure passing the SQL
string.

procedure TdmSomeDatamodule.OpenData(const SQL: String);
begin
with qSomeQuery do
begin { Start of with ado ... do }
try { Start of try...except block }
Close;
if Length(SQL) > 0 then
begin
SQL.Text := SQL;
ExecSQL;
end;
except
on e: Exception do
begin
{set an custom error message property, raise a more 'user
friendly' error, etc}
end;
end; { End of try...except block }
end; { End of with ado.. do }
end;

Now the UI..
{some button click}
begin
dmSomeDatamodule.OpenData(Memo1.Lines.Text);
end;

Good luck,
krf
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) 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.