Recent

Author Topic: mysql_query syntax error while sql string have length more than 256 chars  (Read 4995 times)

andipurwito

  • Newbie
  • Posts: 6
    • http://golekupo.blogspot.com
I have an error like this :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bla..bla..' at line 1.


while call my function below:

function InsertSQL(strSQL: AnsiString; CS: TCriticalSection; var ErrMsg: AnsiString): boolean;
var
  td: TDBCfg;
  SockMySQL: PMySQL;
  SQL: PChar;
begin
  CS.Acquire;

  Result := False;
  try
    {alokasi memory query}
    SQL := StrAlloc(Length(strSQL)+1);

    {Get database settings}
    td := TDbCfg.Create;
    td := GetDbConfig;

    {Make MySQL Connection}
    if CreateDbConn(td, SockMySQL, ErrMsg) then
    begin
      StrPCopy(SQL, strSQL);
      if mysql_query(SockMySQL, SQL) <> 0 then
        ErrMsg := 'InsertSQL->'+PCharToStr(mysql_error(SockMySQL))
      else
        Result := True;
    end;
  except on E:Exception do
    ErrMsg := 'InsertSQL->'+E.Message;
  end;
  td.Free;
  StrDispose(SQL);
  mysql_close(SockMySQL);

  CS.Release;
end;

The function always got this error while length of my strSQL contains more than 256 chars.
Anyone can help me to fix this function?

Thanks and best regard!
GolekUpo.Org

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: mysql_query syntax error while sql string have length more than 256 chars
« Reply #1 on: September 01, 2010, 11:55:08 am »
See my answer in FPC forum

 

TinyPortal © 2005-2018