代碼應改為如下:
ClientDataSet1.CommandText:='update user set constrain=:id where loginid=:loin';
ClientDataSet1.Params.Clear;
ClientDataSet1.Params.CreateParam(ftString,'id',ptInput);
ClientDataSet1.Params.CreateParam(ftString,'idin',ptInput);
ClientDataSet1.Params[0].AsString:='56';
ClientDataSet1.Params[1].AsString:='12001';
ClientDataSet1.Execute;
原因是上述操作沒有返回結果集,只能用Excute執行,類似Query.ExecSQL.
另外如果沒有靜態Param,需在程序中動態創建.