Q&A

  • sql 에러인데요...and 근처구문이 틀렸데요...
with Query1 Do

begin

Close;

SQL.Clear;

SQL.ADD('Delete from MATSHM');

if rbndelete.checked then

begin

SQL.ADD(' where SHMDAT = ' + mskolddat.text + '');

SQL.ADD(' and SHMCONNO = ''' + cbxOld_CONNO.text + '''');

if txtspl.text <> '' then sql.add(' and shmspl = ''' + txtspl.text + ''' ');

end;

if rbnUpdate.checked then

sql.add(' where shmspl = ''' + txtspl.text + ''' ');

if mskodno.text <> '' then sql.add(' and shmodno = ''' + mskodno.text + ''' ');

ExecSQL; ---> 여기서 에러가 납니다.

Close;

end;



위와같은 문장을 실행하는데 and 구문근처에서 에러가 났다고 메세지가 뜹니다. and 근처구문을 어떻게 바꿔야 하는지요...좀 알려주세요..부탁드려요.

2  COMMENTS
  • Profile
    이지인 2001.11.15 01:42
    아랫님이 쿼테이션 에러일거 같다라고 했는데요...

    그것땜에 에러도 잦고 헷갈리기도 하죠?

    그래서 제가 자주 쓰는 팁을 적을께요.



    var

    QUOTE: String = '"';



    이렇게 선언해 두구요..

    문장 작성할때에 ''' 대신 QUOTE를 씁니다.

    헷갈리지 않겠죠?





    이하은 wrote:

    > with Query1 Do

    > begin

    > Close;

    > SQL.Clear;

    > SQL.ADD('Delete from MATSHM');

    > if rbndelete.checked then

    > begin

    > SQL.ADD(' where SHMDAT = ' + mskolddat.text + '');

    > SQL.ADD(' and SHMCONNO = ''' + cbxOld_CONNO.text + '''');

    > if txtspl.text <> '' then sql.add(' and shmspl = ''' + txtspl.text + ''' ');

    > end;

    > if rbnUpdate.checked then

    > sql.add(' where shmspl = ''' + txtspl.text + ''' ');

    > if mskodno.text <> '' then sql.add(' and shmodno = ''' + mskodno.text + ''' ');

    > ExecSQL; ---> 여기서 에러가 납니다.

    > Close;

    > end;

    >

    > 위와같은 문장을 실행하는데 and 구문근처에서 에러가 났다고 메세지가 뜹니다. and 근처구문을 어떻게 바꿔야 하는지요...좀 알려주세요..부탁드려요.

  • Profile
    용이... 2001.11.15 00:46
    쿼테이션 마크를 잘못 찍은거 같은데여....

    이렇게 한번 해보세여...



    > with Query1 Do

    > begin

    > Close;

    > SQL.Clear;

    > SQL.ADD('Delete from MATSHM');

    > if rbndelete.checked then

    > begin

    > SQL.ADD(' where SHMDAT = ''' + mskolddat.text+'''');

    > SQL.ADD(' and SHMCONNO = ''' + cbxOld_CONNO.text + '''');

    > if txtspl.text <> '' then sql.add(' and shmspl = ''' + txtspl.text + '''');

    > end;

    > if rbnUpdate.checked then

    > sql.add(' where shmspl = ''' + txtspl.text + '''');

    > if mskodno.text <> '' then sql.add(' and shmodno = ''' + mskodno.text + ''' ');

    > ExecSQL;

    > Close;

    > end;

    >



    그리고...검색하기 위한 조건값을 직접 넣어도 되지만...

    ParamByname으로 하는것이 나중에 보기가 쉽고...유지보수하기도 쉬울거 같네여...

    물론...프로그래머 마음이지만이여...

    그럼...