飞
飞骐
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我写的一段更新Blob类型数据的代码,结果老是出现parameter xxx not found的错误
var
ms: TMemoryStream;
begin
ms:= TMemoryStream.Create;
try
try
ClientDataSet1.Close;
RichViewEdit1.SaveRVFToStream(ms,false);
ms.Position := 0;
ClientDataSet1.CommandText := 'Update test set content=:content where id=:id';
ClientDataSet1.Params.Clear;
ClientDataSet1.Params.CreateParam(ftBlob, 'content', ptInput);
ClientDataSet1.Params.CreateParam(ftSmallInt, 'id', ptInput);
ClientDataSet1.Params.ParamByName('id').AsInteger := StrToIntDef(Edit1.Text,10);
TBlobField(ClientDataSet1.Params.ParamByName('content')).LoadFromStream(ms);
ClientDataSet1.Execute;
ClientDataSet1.ApplyUpdates(0);
except
on e: Exception do
MessageDlg('save 失败!', mtError, [mbOK], 0);
end; // try/except
finally // wrap up
ClientDataSet1.Close;
ms.Free;
end; // try/finally
MessageDlg('Save 成功!', mtWarning, [mbOK], 0);
end;
var
ms: TMemoryStream;
begin
ms:= TMemoryStream.Create;
try
try
ClientDataSet1.Close;
RichViewEdit1.SaveRVFToStream(ms,false);
ms.Position := 0;
ClientDataSet1.CommandText := 'Update test set content=:content where id=:id';
ClientDataSet1.Params.Clear;
ClientDataSet1.Params.CreateParam(ftBlob, 'content', ptInput);
ClientDataSet1.Params.CreateParam(ftSmallInt, 'id', ptInput);
ClientDataSet1.Params.ParamByName('id').AsInteger := StrToIntDef(Edit1.Text,10);
TBlobField(ClientDataSet1.Params.ParamByName('content')).LoadFromStream(ms);
ClientDataSet1.Execute;
ClientDataSet1.ApplyUpdates(0);
except
on e: Exception do
MessageDlg('save 失败!', mtError, [mbOK], 0);
end; // try/except
finally // wrap up
ClientDataSet1.Close;
ms.Free;
end; // try/finally
MessageDlg('Save 成功!', mtWarning, [mbOK], 0);
end;