Ver Mensaje Individual
  #6  
Antiguo 18-10-2005
SMTZ SMTZ is offline
Miembro
 
Registrado: nov 2003
Posts: 225
Reputación: 21
SMTZ Va por buen camino
Post Dataset manual

Buenas, al final he optado por crear el dataset a mano. No es lo que me hubiera gustado, que para eso existen los componentes graficos, pero funciona:

=======================

unit WinFormU;

interface

uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, System.Globalization,
Borland.Data.Provider, DataSetU;

type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
DataGrid1: System.Windows.Forms.DataGrid;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;

[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$AUTOBOX ON}

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
begin
Self.DataGrid1 := System.Windows.Forms.DataGrid.Create;
(System.ComponentModel.ISupportInitialize(Self.DataGrid1)).BeginInit;
Self.SuspendLayout;
//
// DataGrid1
//
Self.DataGrid1.DataMember := '';
Self.DataGrid1.HeaderForeColor := System.Drawing.SystemColors.ControlText;
Self.DataGrid1.Location := System.Drawing.Point.Create(8, 16);
Self.DataGrid1.Name := 'DataGrid1';
Self.DataGrid1.Size := System.Drawing.Size.Create(280, 240);
Self.DataGrid1.TabIndex := 0;
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
Self.ClientSize := System.Drawing.Size.Create(292, 266);
Self.Controls.Add(Self.DataGrid1);
Self.Name := 'TWinForm';
Self.Text := 'WinForm';
(System.ComponentModel.ISupportInitialize(Self.DataGrid1)).EndInit;
Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;

end.

=======================

unit DataSetU;

interface

Uses
System.Data, Borland.Data.Provider;

Type
TMiBD = Record
MiDataSet : DataSet;
MiAdaptador : BdpDataAdapter;
MiConexion : BdpConnection;
MiComando : BdpCommand;

End;

Var
MiBD : TMiBD;

implementation

Begin

With MiBD Do
Begin

MiDataSet := DataSet.Create ( 'MiBD');

MiConexion := BdpConnection.Create;
MiConexion.ConnectionOptions := 'transaction isolation' +
'=ReadCommitted';
MiConexion.ConnectionString := 'database=Ecodomes;asse' +
'mbly=Borland.Data.Oracle, Version=2.0.0.0, Culture=neutral, PublicKeyToke' +
'n=91d62ebb5b0d1b1b;vendorclient=oci.dll;provider=Oracle;username=system;p' +
'assword=cz4lg3';

MiComando := Borland.Data.Provider.BdpCommand.Create;
MiComando.CommandOptions := nil;
MiComando.CommandText := 'select * from usuarios';
MiComando.CommandType := System.Data.CommandType.Text;
MiComando.Connection := MiConexion;
MiComando.ParameterCount := (SmallInt(0));
MiComando.SchemaName := nil;
MiComando.Transaction := nil;
MiCOmando.UpdatedRowSource := System.Data.UpdateRowSource.None;

MiAdaptador := BDPDataAdapter.Create;
MiAdaptador.DataSet := MiDataSet;
MiAdaptador.SelectCommand := MiComando;
MiAdaptador.SelectCommand.CommandText := 'select * from usuarios';
MiAdaptador.Fill(MiDataSet);
MiAdaptador.Active := True;

End;

end.
Responder Con Cita