改成:
values (10,''非法登陆名为&'+edtUserName.Text+''','''+leftstr

解决方案 »

  1.   

    改为这样试试:
    strsqlwarning:='insert into operatelog (infoType,content,[date],[time]) values (10,''非法登陆名为'''+'&'''+edtUserName.Text+''','''+leftstr(datetimetostr(now),8)+''','''+rightstr(datetimetostr(now),8)+''')';
      

  2.   

    我把SQL语句读出来如下
     insert into operatelog (infoType,content,[date],[time]) values (10,'非法登陆名为为'非法登陆名为&esrewr','2001-8-21 13:10:05','2001-8-21 13:10:05')
    另外为什么我用 leftstr()函数竟然连编译都通不过,我是不用leftstr()函数才把该SQL语句读出来
      

  3.   

    使用 left 代替 leftstr
      

  4.   

    1、leftstr好像Delphi没有这个函数。
    SQL的毛病就在这里
    '非法登陆名为为'非法登陆名为&esrewr'
                  ^
    中间多了一个引号,如果这样,有两种方法,一种是象Delphi一样,打两个引号转义。
    另一种事改为
    "非法登陆名为为'非法登陆名为&esrewr"
      

  5.   

    不行就转成两个单引号,最好先在ACCESS里sql视图执行一下通过
      

  6.   

    谢谢,上面的问题已经解决
    不过leftstr的问题没有解决,delphi中有DELPHI这个函数,而没有left这个函数帮助文件如下Returns the substring of a specified length that appears at the start of a string.UnitStrUtilsCategorystring handling routinesfunction LeftStr(const AText: string; ACount: Integer): string;DescriptionLeftStr returns the leading characters of AText up to a length of ACount characters. Thus, for example,LeftStr('Programmer', 7)编译器给的错误为Undeclared identifier: 'leftstr'
      

  7.   

    我的Delphi5里面可没有这个函数。
    不过可以给你几个等价的函数
    function StrLeft(const S: AnsiString; Count: Integer): AnsiString;
    begin
      Result := Copy(S, 1, Count);
    end;function StrRight(const S: AnsiString; Count: Integer): AnsiString;
    begin
      Result := Copy(S, Length(S) - Count + 1, Count);
    end;