Board index » delphi » Create a Recordset by code.

Create a Recordset by code.

Somebody posted some code to create a recordset directly by code, instead of
using an TADOConnection and a Tdataset inherited object...
Could u post it again? i can't find it on the newsgroup....(donno why)

thanks!

 

Re:Create a Recordset by code.


Quote
"Emiliano Sosa" <es...@gosierra.com> wrote in message

news:3cc86057_1@dnews...

Quote
> Somebody posted some code to create a recordset directly by code, instead
of
> using an TADOConnection and a Tdataset inherited object...
> Could u post it again? i can't find it on the newsgroup....(donno why)

http://groups.google.com/groups?hl=en&selm=3c9efed7_2%40dnews

Andy Mackie.

Re:Create a Recordset by code.


thanks, but that was not the code...
somebody posted a code replacing the following operation without a TDataset
/ TAdoConnection.

Connection.Open;
Table.Open;
Table.First;
while not Table.EOF do begin
  .
  .
  .
   Table.Next;
end;

Thanks!

Re:Create a Recordset by code.


Was it..

==
coCommand Example:

http://www.adoanywhere.com/examples/delphi/coCmd.zip

The example uses the coCommand object rather than AdoExpress TAdoCommand
object.

I wrote it quickly as an answer to previous thread, it works but you will
have to modify it to suit your own needs.

The result set is read only.
==

--
Michael Collier Bsc (Hons)
Interactive ADO Object Browser
www.adoanywhere.com
m...@adoanywhere.com
--

Quote
"Emiliano Sosa" <es...@gosierra.com> wrote in message

news:3cc86057_1@dnews...
Quote
> Somebody posted some code to create a recordset directly by code, instead
of
> using an TADOConnection and a Tdataset inherited object...
> Could u post it again? i can't find it on the newsgroup....(donno why)

> thanks!

Re:Create a Recordset by code.


Here's code to create a ADO recordset using the ADOInt unit (ADO type lib).

var
  RatingsList : Recordset20;
begin
    RatingsList := CoRecordset.Create;

    RatingsList.Fields.Append('Service', adVarChar, 10, adFldIsNullable);
    RatingsList.Fields.Append('Code', adVarChar, 10, adFldIsNullable);
    RatingsList.Fields.Append('Value', adInteger, -1, adFldIsNullable);

    RatingsList.Open(EmptyParam, EmptyParam, adOpenUnspecified,
adLockUnspecified,
                     adCmdUnspecified);
end;

To update data in that recordset:

      RatingsList.AddNew(EmptyParam, EmptyParam);
      RatingsList.Fields.Item ['Service'].Value := 'MyService';
      RatingsList.Fields.Item ['Code'].Value := 'XXXX'
      RatingsList.Fields.Item ['Value'].Value := 3;
      RatingsList.Update(EmptyParam, EmptyParam);

Here's code to create a TADODataset.

var
  MyDataset : TADODataset;
begin
  MyDataset := TADODataset.Create (nil);

  with TStringField.Create (MyDataset) do
  begin
    FieldName := 'MyField1';
    Size := 10;
    Dataset := MyDataset;
  end;
  with TIntegerField.Create (MyDataset) do
  begin
    FieldName := 'MyField2';
    Dataset := MyDataset;
  end;
  with TBooleanField.Create (MyDataset) do
  begin
    FieldName := 'MyField3';
    Dataset := MyDataset;
  end;

  MyDataset.CreateDataset;
end;

To update data in that TADODataset:

  dsData.Append;

  dsData.FieldValues ['MyField1'] := 'Text';
  dsData.FieldValues ['MyField2'] := 2;
  dsData.FieldValues ['MyField3'] := True;
  dsData.Post;

Hope this helps....

Quote
"Emiliano Sosa" <es...@gosierra.com> wrote in message

news:3cc86057_1@dnews...
Quote
> Somebody posted some code to create a recordset directly by code, instead
of
> using an TADOConnection and a Tdataset inherited object...
> Could u post it again? i can't find it on the newsgroup....(donno why)

> thanks!

Re:Create a Recordset by code.


Thanks Shannon for your code.. It was pretty helpfull..
I'd take you to have a drink somewhere in return for your answers (my other
posts), but i can't through the internet  (yet.)

Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

Other Threads