The following example uses a blob stream to write a string to the end of the Notes field in the Tasks table.procedure TForm1.AppendNoteClick(Sender: TObject);var
Stream: TStream;
S: string;
begin
with Tasks do
begin Edit; if State = dsEdit then
begin
Stream := CreateBlobStream(FieldByName('Notes'), bmReadWrite);
try
Stream.Seek(0, 2); {Seek 0 bytes from the stream's end point}
S := ' This line will be added to the end.';
Stream.Write(PChar(S)^, Length(S));
Post;
finally
Stream.Free;
end;
end;
end;
end;
这是例子,你看看!还有就是你确定你的FORM用了dm吗?
Stream: TStream;
S: string;
begin
with Tasks do
begin Edit; if State = dsEdit then
begin
Stream := CreateBlobStream(FieldByName('Notes'), bmReadWrite);
try
Stream.Seek(0, 2); {Seek 0 bytes from the stream's end point}
S := ' This line will be added to the end.';
Stream.Write(PChar(S)^, Length(S));
Post;
finally
Stream.Free;
end;
end;
end;
end;
这是例子,你看看!还有就是你确定你的FORM用了dm吗?
if dsedit in dm.query1.State then
出现这样的错误,怎么回事啊
就肯定可以了
uses db;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, Mask, DBCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
DBEdit1: TDBEdit;
Query1: TQuery;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
query1.Insert;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if query1.State is [dsinsert] thenend;end.
改为
if query1.State in [dsinsert] then
通过