Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql statement in delphi

Status
Not open for further replies.

Pietjeparasietje

Programmer
Jun 13, 2005
55
NL
Hi guys,

I'm going nuts here, cannot figure out why the following statement is not working:

Code:
qryDetail.SQL.text := 'Select * from WoHistory where TotalFinal <> '+QuotedStr('')+' order by WorkOrderNo';

Please help me!
Peter
 
Do you get an error message? No records returned? Other than the fact that I use the .Add method instead of text, the SQL looks fine.

Have you verified that the query you think you're running is what is actually being passed? I usually use the Text method in a message box to make sure it's all right:

Code:
With qryDetail do
begin
  SQL.Clear;
  SQL.Add('Select * from WoHistory where TotalFinal <> '+QuotedStr('')+' order by WorkOrderNo');
  ShowMessage(SQL.Text);
  Active := True;
end;

Sorry it's not more helpful!!

Leslie
 
Thanks so far, i've tried your way.
I know that the query is right, as soon as I leave the where statement out or the order by statement its working fine. But if I use them together I get the following message:

---------------------------
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
---------------------------
any suggestions?

Peter
 

Try this:
Code:
qryDetail.SQL.text := 'Select * from WoHistory where TotalFinal is not NULL order by WorkOrderNo';
 
Keeps giving me the error message I posted before..
I'm really starting to lose it man...
 

"Too few parameters. Expected 1." usually means you have something in your query that is referencing a variable and not an actual column name in the query.

Do you really have a column named "TotalFinal" in the table named "WoHistory"? (You said it works when you leave out the WHERE clause.)

A minor point: You should begin the sequence with qryDetail.Close just as a safeguard in case the previous use of qryDetail did not clean up after itself.



 
Just to correct Zathras's WHERE

where NOT TotalFinal is NULL order by WorkOrderNo

Have you checked your Params property (in object inspector) to make sure there's no parameters in there? Delete any entries that might be in it.

lou
 
Thnx guys for your help!!
using the where not statement is finally working. I've re-created the table and for some reason that seemed to help.
Thanks!

Peter
 

lou, thanks for your input, but BOTH forms are acceptable in Microsoft SQL Server, Microsoft Access and in Gupta SQLBase, just to mention three.

 
Zathras, you are right once again. I should give up this programming lark, I'm no good at it [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top