Subject | Re: [IBO] Inserts using TIB_Cursor |
---|---|
Author | Ross Williams |
Post date | 2003-03-07T18:16:12Z |
I obviously wasn't very clear.
My code for the insert looks like this:
Function InsertMediaRecord: TModalResult;
Begin
With TMediaEditForm.Create(nil) do
Try
With TIB_CURSOR(MediaCursorDataSource.DataSet) do
Begin
IB_Transaction.StartTransaction;
Open;
Insert;
end;
Result := ShowModal;
If Result = mrOK then
Begin
MediaCursorDataSource.DataSet.Post;
MediaCursorDataSource.DataSet.IB_Transaction.Commit;
end
else
Begin
MediaCursorDataSource.DataSet.Cancel;
MediaCursorDataSource.DataSet.Close;
MediaCursorDataSource.DataSet.IB_Transaction.Rollback;
end;
finally
Free;
end;
end;
MediaCursorDataSource is on the TMediaEditForm and has its dataset set at
design time to the TIBO_Cursor on a datamodule. This similar procedure does
work for editing a record:
Function EditMediaRecord(ID:Integer): TModalResult;
Begin
With TMediaEditForm.Create(nil) do
Try
With TIB_CURSOR(MediaCursorDataSource.DataSet) do
Begin
IB_Transaction.StartTransaction;
ParamByName('p' + MEDIAID).AsInteger := ID;
Open;
Edit;
end;
Result := ShowModal;
If Result = mrOK then
Begin
MediaCursorDataSource.DataSet.Post;
MediaCursorDataSource.DataSet.IB_Transaction.Commit;
end
else
Begin
MediaCursorDataSource.DataSet.Cancel;
MediaCursorDataSource.DataSet.Close;
MediaCursorDataSource.DataSet.IB_Transaction.RollBack;
end;
finally
Free;
end;
end;
This cursor is used exclusively for editing and inserting records.
At 09:43 AM 3/7/03, you wrote:
Citizens for Sensible Transportation/
Coalition for a Livable Future
Terminal Sales Building
1220 SW Morrison, Suite 535
Portland OR 97205
Phone: 503-225-0003
Fax: 503-225-0333
Web: www.cfst.org
Email: ross@...
My code for the insert looks like this:
Function InsertMediaRecord: TModalResult;
Begin
With TMediaEditForm.Create(nil) do
Try
With TIB_CURSOR(MediaCursorDataSource.DataSet) do
Begin
IB_Transaction.StartTransaction;
Open;
Insert;
end;
Result := ShowModal;
If Result = mrOK then
Begin
MediaCursorDataSource.DataSet.Post;
MediaCursorDataSource.DataSet.IB_Transaction.Commit;
end
else
Begin
MediaCursorDataSource.DataSet.Cancel;
MediaCursorDataSource.DataSet.Close;
MediaCursorDataSource.DataSet.IB_Transaction.Rollback;
end;
finally
Free;
end;
end;
MediaCursorDataSource is on the TMediaEditForm and has its dataset set at
design time to the TIBO_Cursor on a datamodule. This similar procedure does
work for editing a record:
Function EditMediaRecord(ID:Integer): TModalResult;
Begin
With TMediaEditForm.Create(nil) do
Try
With TIB_CURSOR(MediaCursorDataSource.DataSet) do
Begin
IB_Transaction.StartTransaction;
ParamByName('p' + MEDIAID).AsInteger := ID;
Open;
Edit;
end;
Result := ShowModal;
If Result = mrOK then
Begin
MediaCursorDataSource.DataSet.Post;
MediaCursorDataSource.DataSet.IB_Transaction.Commit;
end
else
Begin
MediaCursorDataSource.DataSet.Cancel;
MediaCursorDataSource.DataSet.Close;
MediaCursorDataSource.DataSet.IB_Transaction.RollBack;
end;
finally
Free;
end;
end;
This cursor is used exclusively for editing and inserting records.
At 09:43 AM 3/7/03, you wrote:
>Ross Williams wrote:Ross Williams
> >
> > I can't get an insert to work with the TIB_Cursor. I have a form set up
> > that I use for editing that works fine. I set the cursor to live and it
> > edits. When I try inserting a new record - I start the transaction, insert
> > the record, enter values in the same form I am using for editing and then
> > post it and commit the transaction. There is no error, but the record is
> > not posted or committed. I then tried adding insertsql property to
> > explicitly create the insert. I used the sql generated by a TIB_Query for
> > the same table and pasted it into the instertsql property. The result was
> > the same.
> >
> > How does this work?
> >
>
>The TIB_Cursor is basically for reports. Start at the beginning and
>process once.
>
>Use the grid.
>--
>Raymond Kennington
>Programming Solutions
>W2W Team B
>
>
>___________________________________________________________________________
>IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
>___________________________________________________________________________
>http://www.ibobjects.com - your IBO community resource for Tech Info papers,
>keyword-searchable FAQ, community code contributions and more !
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Citizens for Sensible Transportation/
Coalition for a Livable Future
Terminal Sales Building
1220 SW Morrison, Suite 535
Portland OR 97205
Phone: 503-225-0003
Fax: 503-225-0333
Web: www.cfst.org
Email: ross@...