Q&A

  • 델파이네의 다음 SQL문이 에러를 냅니다..
General SQL error [MySQL][ODBC 3.51 Driver][ You have an error in your SQL syntax near 'Insert into users values(no_,'1','1','1','1',1','1','1','' at line 2      

no_      := strToint(edtNo.Text);
        dong_    := edtDong.Text;
        year_    := cmbYear.Text;
        ya_      := edtYa.Text;
        name_    := edtName.Text;
        number_  := edtNumber.Text;
        post_    := edtPost.Text;
        city_    := cmbCity.Text;
        address_ := edtAddress.Text;
        phone_   := edtPhone.Text;
        hphone_  := edthPhone.Text;
        tel_     := edtTel.Text;
        job_     := edtJob.Text;
        sch_     := edtSch.Text;
        ch_      := edtCh.Text;
        fa_      := edtFa.Text;
        ja_      := edtJa.Text;
        gun_     := edtGun.Text;

        with frmMain.sqlUser do begin
        close;
        SQL.Add('Insert into users values');
        SQL.Add(' (no_,'''+dong_+''','''+year_+''','''+ya_+''', ');
        SQL.Add(' '''+name_+''','''+number_+''','''+post_+''','''+city_+''', ');
        SQL.Add(' '''+address_+''','''+phone_+''','''+hphone_+''','''+tel_+''', ');
        SQL.Add(' '''+job_+''','''+sch_+''','''+ch_+''','''+fa_+''', ');
        SQL.Add(' '''+ja_+''','''+gun_+''')');

        if Prepared = false then Prepare;
        ExecSQL;
        end;

no_이 숫자로 안나오고 no_로 나오고요.
address_부분부터 에러가 납니다.
1  COMMENTS
  • Profile
    장지용 2002.02.21 01:36
    그냥 파라미터로 쓰시는게 편할건데요.

    strSQL := 'insert into users values(:no, :dong, :year, ...)';
    SQL.Add(strSQL);
    ParamByName('no').AsString := no;
    ParamByName('dong').AsString := dong;
    ParamByName('year').AsString := year;
    ...