•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 426,141 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,659 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 2243 | Replies: 2 | Solved
![]() |
•
•
Join Date: Apr 2006
Location: CA, USA
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I am having difficult time to make this run. Can anyone help me please?.
I have test form with 3 command buttons & one Richedit.Im using access database to test. It have just one table with two fields ID (Integer), sMemo (memo). I am trying to save richedit text (rtf format) to table. When I run this code I get an error 'Database is not in insert or edit mode' I cant get pass that error any idea?
Thank you
unit Blobtest;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, JvExStdCtrls, JvRichEdit,Db, ADODB;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
JvRichEdit1: TJvRichEdit;
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
sConnString: String;
connADO : TADOConnection;
bConnectionSuccesful:Boolean=false;
ADODataSet1 :TADODataSet; //used to select data
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
//Clear
JvRichEdit1.Clear;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
blobF : TBlobField ;
bs : TStream;
begin
//Save
ADODataSet1 := TADODataSet.Create(ADODataSet1);
ADODataSet1.Connection := connADO;
ADODataSet1.CommandType := cmdText;
ADODataSet1.CursorType := ctKeySet;
ADODataSet1.CommandText :='Select * from table1';
ADODataSet1.Active := True;
ADODataSet1.First;
ADODataSet1.Edit;
blobF := ADODataSet1.FieldByName('sMemo') as TBlobField;
bs := ADODataSet1.CreateBlobStream(blobF, bmWrite) ;
blobF.Clear;
blobF.SetFieldType(ftMemo);
blobF.LoadFromStream(bs);
ADODataSet1.Post;
ADODataSet1.free;
blobF := nil;
blobF.Free;
bs.Free;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
//Load
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
sConnString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb ;Persist Security Info=False;Jet OLEDB: Database Password=''''';
connADO := TADOConnection.Create(connADO);
connADO.ConnectionString := sConnString;
connADO.LoginPrompt := False ;
connADO.Connected := true;
end;
end.
I am having difficult time to make this run. Can anyone help me please?.
I have test form with 3 command buttons & one Richedit.Im using access database to test. It have just one table with two fields ID (Integer), sMemo (memo). I am trying to save richedit text (rtf format) to table. When I run this code I get an error 'Database is not in insert or edit mode' I cant get pass that error any idea?
Thank you
unit Blobtest;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, JvExStdCtrls, JvRichEdit,Db, ADODB;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
JvRichEdit1: TJvRichEdit;
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
sConnString: String;
connADO : TADOConnection;
bConnectionSuccesful:Boolean=false;
ADODataSet1 :TADODataSet; //used to select data
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
//Clear
JvRichEdit1.Clear;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
blobF : TBlobField ;
bs : TStream;
begin
//Save
ADODataSet1 := TADODataSet.Create(ADODataSet1);
ADODataSet1.Connection := connADO;
ADODataSet1.CommandType := cmdText;
ADODataSet1.CursorType := ctKeySet;
ADODataSet1.CommandText :='Select * from table1';
ADODataSet1.Active := True;
ADODataSet1.First;
ADODataSet1.Edit;
blobF := ADODataSet1.FieldByName('sMemo') as TBlobField;
bs := ADODataSet1.CreateBlobStream(blobF, bmWrite) ;
blobF.Clear;
blobF.SetFieldType(ftMemo);
blobF.LoadFromStream(bs);
ADODataSet1.Post;
ADODataSet1.free;
blobF := nil;
blobF.Free;
bs.Free;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
//Load
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
sConnString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb ;Persist Security Info=False;Jet OLEDB: Database Password=''''';
connADO := TADOConnection.Create(connADO);
connADO.ConnectionString := sConnString;
connADO.LoginPrompt := False ;
connADO.Connected := true;
end;
end.
•
•
Join Date: Dec 2006
Location: Romania
Posts: 171
Reputation:
Rep Power: 2
Solved Threads: 16
1)i haven't worked with ADO, so i can not give you an 100% accurate answer. i took a look into your code and in my opinion everything looks ok.
i'm working a lot with IBObjects, and from there i now that if the database object hasn't requestlive property set to true, then nothing isn't saved into your database even your quey return that the posting event has been accomplished. why your database is not in the insert/edit mode i can not figure out.
2) try to debbug your code using watch and see what's happening with your querry and variables
3) here you can find some topics regarding how to code using ADO
http://delphi.about.com/sitesearch.h...de=3176&type=1
best regards,
i'm working a lot with IBObjects, and from there i now that if the database object hasn't requestlive property set to true, then nothing isn't saved into your database even your quey return that the posting event has been accomplished. why your database is not in the insert/edit mode i can not figure out.
2) try to debbug your code using watch and see what's happening with your querry and variables
3) here you can find some topics regarding how to code using ADO
http://delphi.about.com/sitesearch.h...de=3176&type=1
best regards,
Last edited by radu84 : May 18th, 2007 at 12:29 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- VB6 Database Program (Visual Basic 4 / 5 / 6)
- The Datagrid: How does one fill text boxes in edit mode with their original content? (ASP.NET)
- DataGrid: Edit mode, the index of a dropdownlist does not start at the right Value (ASP.NET)
- Php newsletter error (PHP)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Modify Delphi code with seperate application
- Next Thread: !!! Help ME !!!!!


Linear Mode