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 

SQL 2005 Express, BDS2006 and parametized queries

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Pepe T
Guest





PostPosted: Wed Mar 07, 2007 11:18 am    Post subject: SQL 2005 Express, BDS2006 and parametized queries Reply with quote



This works with the BDE, Advantage Local Server and MS SQL 2000. Why it
doesn't work with SQL 2005 Express and BDS2006 with update 2, and CoreLab's
SDAC component?
I use the same conbination with the other 3 databases.

procedure TForm1.Button1Click(Sender: TObject);
Var
S : String;
begin
S := Edit1.Text + '%';
with MSQuery1 do
begin
SQL.Clear;
SQL.Add('Select * from Customers');
SQL.Add('where');
SQL.Add('CustomerName LIKE :CustomerName');
Prepare;
Params[0].Value := S;
Open;
end;
end;


Any help is apreciated. Thanks in advance
Pepe
Back to top
Mikael Eriksson
Guest





PostPosted: Wed Mar 07, 2007 1:35 pm    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote



Hi!

What happens when it does not work, Exception, no data returned?
Have you tried TADOQuery instead?

If TADOQuery works then my guess would be that you have to look in
the SDAC component for the failure.

/Micke
Back to top
Pepe Taboada
Guest





PostPosted: Wed Mar 07, 2007 10:13 pm    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote



I get no Exception. I get no data return. But if I hardcode the SQL
statements in the Query component as this:
.......
where
CustomerName LIKE 'W%'
.....

then I get a result.
Thanks


"Mikael Eriksson" <micke314 (AT) gmail (DOT) com> wrote in message
news:45ee6acd$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi!

What happens when it does not work, Exception, no data returned?
Have you tried TADOQuery instead?

If TADOQuery works then my guess would be that you have to look in
the SDAC component for the failure.

/Micke

Back to top
Mikael Eriksson
Guest





PostPosted: Thu Mar 08, 2007 1:01 am    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote

Pepe Taboada skrev:
Quote:
I get no Exception. I get no data return. But if I hardcode the SQL
statements in the Query component as this:
......
where
CustomerName LIKE 'W%'
....

then I get a result.
Thanks


You can use SQL Server Profiler and start a trace to see how the select
statement is built.

That may give you a hint to what is wrong.

I tried it with a TADOQuery and the select statement was

exec sp_executesql N'Select * from Customers
where
CustomerName LIKE @P1
',N'@P1 varchar(50)','Edit1%'


/Micke
Back to top
Pepe Taboada
Guest





PostPosted: Thu Mar 08, 2007 8:35 pm    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote

It used TADOQuery and it worked. I guess the problem is with CoreLab's
component. I'll post the resul on their newsgroup.
Thanks anyway
Pepe


"Mikael Eriksson" <micke314 (AT) gmail (DOT) com> wrote in message
news:45ef0b6a$1 (AT) newsgroups (DOT) borland.com...
Quote:
Pepe Taboada skrev:
I get no Exception. I get no data return. But if I hardcode the SQL
statements in the Query component as this:
......
where
CustomerName LIKE 'W%'
....

then I get a result.
Thanks


You can use SQL Server Profiler and start a trace to see how the select
statement is built.

That may give you a hint to what is wrong.

I tried it with a TADOQuery and the select statement was

exec sp_executesql N'Select * from Customers
where
CustomerName LIKE @P1
',N'@P1 varchar(50)','Edit1%'


/Micke
Back to top
Leapin
Guest





PostPosted: Thu Mar 22, 2007 11:00 pm    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote

You probably are missing the quotes in your like statement
try

const DQ = '''';

SQL.Add('CustomerName LIKE '+DQ+':CustomerName'+DQ);

good luck

if you are building the SQL statment why bother using a parameter?



"Pepe T" <pepe.taboada (AT) verizon (DOT) net> wrote in message
news:45ee4b46 (AT) newsgroups (DOT) borland.com...
Quote:
This works with the BDE, Advantage Local Server and MS SQL 2000. Why it
doesn't work with SQL 2005 Express and BDS2006 with update 2, and
CoreLab's SDAC component?
I use the same conbination with the other 3 databases.

procedure TForm1.Button1Click(Sender: TObject);
Var
S : String;
begin
S := Edit1.Text + '%';
with MSQuery1 do
begin
SQL.Clear;
SQL.Add('Select * from Customers');
SQL.Add('where');
SQL.Add('CustomerName LIKE :CustomerName');
Prepare;
Params[0].Value := S;
Open;
end;
end;


Any help is apreciated. Thanks in advance
Pepe
Back to top
Mud
Guest





PostPosted: Sun Apr 15, 2007 8:11 am    Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries Reply with quote

Oh, this one might be too old to bother replying, but why not just avoid the
parameterized stuff and just do something like

SQL.Clear;
SQL.Add('Select * from Customers');
SQL.Add('where CustomerName LIKE ' + QuotedStr(S));
Open;

Or try

SQL.Clear;
SQL.Add('Select * from Customers');
SQL.Add('where CustomerName LIKE :CustomerName');
Prepare;
Params[0].AsString := S;
Open;



"Pepe T" <pepe.taboada (AT) verizon (DOT) net> wrote in message
news:45ee4b46 (AT) newsgroups (DOT) borland.com...
Quote:
This works with the BDE, Advantage Local Server and MS SQL 2000. Why it
doesn't work with SQL 2005 Express and BDS2006 with update 2, and
CoreLab's
SDAC component?
I use the same conbination with the other 3 databases.

procedure TForm1.Button1Click(Sender: TObject);
Var
S : String;
begin
S := Edit1.Text + '%';
with MSQuery1 do
begin
SQL.Clear;
SQL.Add('Select * from Customers');
SQL.Add('where');
SQL.Add('CustomerName LIKE :CustomerName');
Prepare;
Params[0].Value := S;
Open;
end;
end;


Any help is apreciated. Thanks in advance
Pepe

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