 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Pepe T Guest
|
Posted: Wed Mar 07, 2007 11:18 am Post subject: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Wed Mar 07, 2007 1:35 pm Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Wed Mar 07, 2007 10:13 pm Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Thu Mar 08, 2007 1:01 am Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Thu Mar 08, 2007 8:35 pm Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Thu Mar 22, 2007 11:00 pm Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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
|
Posted: Sun Apr 15, 2007 8:11 am Post subject: Re: SQL 2005 Express, BDS2006 and parametized queries |
|
|
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 |
|
 |
|
|
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
|
|