Home > Archive > Microsoft SQL Server forum > August 2005 > Problems with MOD-Function by accessing MS-Access Database via SQL in Delphi









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2005-08-23, 8:24 pm

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 :=3D 'SELECT * FROM database1 WHERE
value1=3D1 AND value2=3D ' + inttostr(array[3]);


ADOQuery1.Open;


Label5. Caption:=3DADOQuery1
. Fiel=ADdByName('valu
e4').AsString;


Now I only want to select these rows, where the Integer value3 ends on
1=2E 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 :=3D 'SELECT * FROM database1 WHERE
value1=3D1 AND value2=3D ' + inttostr(array[3])+' AND MOD(value3,10) =3D 1;


Delphi shows me a Syntax Error in this statement.

Thx for help!

sarah18web

2005-08-23, 8:24 pm

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

2005-08-23, 8:24 pm

On 23 Aug 2005 11:51:15 -0700, sarah18web wrote:

> 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.


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.
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com