数据库:sql server
表:    table1
字段1: priceA   类型: money
字段2:  priceB   类型:  smallmoney sql 语句:
'update table1 set priceA='''+edit1.text+''',priceB='''+edit2.text+''''
执行这个sql语句后出错:
Disallowed implicit conversion from data type varchar to data type money......
Disallowed implicit conversion from data type varchar to data type smallmoney......我知道是sql语句类型处理的问题,但是如何写这个语句呢?谢谢!

解决方案 »

  1.   

    你写错了,应改为:
    'update table1 set priceA='+edit1.text+',priceB='+edit2.text;或者你用参数方式吧:
    sqltext := 'update table1 set priceA=:pricea,priceB=:priceb';
    ...
    query.parambyname('pricea').ascurrency := strtofloat(edit1.text);
    query.parambyname('priceb').ascurrency := strtofloat(edit2.text);
    query.execsql;
    ....
      

  2.   

    查一下DELPHI地LOCAL SQL GUIDE ,检索CONVERT函数。
      

  3.   

    不好意思,自己忙晕了头了,谢谢menliwxj(有缘) ,结贴。
      

  4.   

    呵呵呵你忘记SQL在delphi中的用法了其实就是要连贯成一个字符串后然后看其是否符合SQL语句即可,不行时可以在sql查询中看看就知是否对了,一点小看法
      

  5.   

    update table1 set cast(priceA as string)='+edit1.text+',cast(priceB as string)='+edit2.text;