Connecting Tech Pros Worldwide Forums | Help | Site Map

Problems with MOD-Function by accessing MS-Access Database via SQL in Delphi

sarah18web
Guest
 
Posts: n/a
#1: Aug 23 '05
Hello,
the following problem:

I use Delphi 6 to access a MS Access Database.
In short, the Delphi Code looks like this:


ADOConnection1.Open;
ADOQuery1.Close;
ADOQuery1.SQL.Text := 'SELECT * FROM database1 WHERE
value1=1 AND value2= ' + inttostr(array[3]);


ADOQuery1.Open;


Label5.Caption:=ADOQuery1.Fiel*dByName('value4').A sString;


Now I only want to select these rows, where the Integer value3 ends on
1. So I need the Modulo-Function. I found in the Internet these two
functions:
MOD(x,y) und x % y
But I get an error if I want to use one.

For example, If I change


ADOQuery1.SQL.Text := 'SELECT * FROM database1 WHERE
value1=1 AND value2= ' + inttostr(array[3])+' AND MOD(value3,10) = 1;


Delphi shows me a Syntax Error in this statement.

Thx for help!


sarah18web
Guest
 
Posts: n/a
#2: Aug 23 '05

re: Problems with MOD-Function by accessing MS-Access Database via SQL in Delphi


Sorry, there is a ' missing in the code. But it has nothin to do with
the problem:

The first code runs perfectly, but If I insert
AND MOD(20,10) = 0 there is the syntax error again.

Ross Presser
Guest
 
Posts: n/a
#3: Aug 23 '05

re: Problems with MOD-Function by accessing MS-Access Database via SQL in Delphi


On 23 Aug 2005 11:51:15 -0700, sarah18web wrote:
[color=blue]
> Sorry, there is a ' missing in the code. But it has nothin to do with
> the problem:
>
> The first code runs perfectly, but If I insert
> AND MOD(20,10) = 0 there is the syntax error again.[/color]

Don't know what it might have to do with Delphi; but MOD() is not a
function supported by SQL server. Only the % operator works.
Closed Thread