Ver Mensaje Individual
  #8  
Antiguo 22-10-2005
SMTZ SMTZ is offline
Miembro
 
Registrado: nov 2003
Posts: 225
Reputación: 21
SMTZ Va por buen camino
Post Ejemplo sencillo

unit WinForm;

{En esta unidad insertamos los componentes BdpConnection1 y BdpAdapter1 de la plaeta de componentes y el DataSet lo creamos manualmente a través de una variable.}

interface

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

type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
BdpConnection1: Borland.Data.Provider.BdpConnection;
bdpSelectCommand1: Borland.Data.Provider.BdpCommand;
bdpInsertCommand1: Borland.Data.Provider.BdpCommand;
bdpUpdateCommand1: Borland.Data.Provider.BdpCommand;
bdpDeleteCommand1: Borland.Data.Provider.BdpCommand;
BdpDataAdapter1: Borland.Data.Provider.BdpDataAdapter;
Button1: System.Windows.Forms.Button;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
{$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))]

Var

DatasetPublico : System.Data.DataSet;

implementation

uses WinForm1;

{El datasource del datagrid1 = al dataset creado en la unidad anterior. Este formulario saldrá al presionar al boton1 creado en el formulario anterior.}

{$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
DataSetPublico := System.Data.DataSet.Create;
Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
Self.bdpSelectCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpInsertCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpUpdateCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.bdpDeleteCommand1 := Borland.Data.Provider.BdpCommand.Create;
Self.BdpDataAdapter1 := Borland.Data.Provider.BdpDataAdapter.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
(System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).BeginInit;
Self.SuspendLayout;
//
// BdpConnection1
//
Self.BdpConnection1.ConnectionOptions := 'transaction isolation=ReadCommit' +
'ted';
Self.BdpConnection1.ConnectionString := 'assembly=Borland.Data.Oracle, Ver' +
'sion=2.0.0.0, Culture=neutral, PublicKeyToken=91d62ebb5b0d1b1b;vendorclie' +
'nt=oci.dll;database=Ecodomes;provider=Oracle;username=system;password=cz4' +
'lg3';
//
// bdpSelectCommand1
//
Self.bdpSelectCommand1.CommandOptions := nil;
Self.bdpSelectCommand1.CommandText := 'select * from usuarios';
Self.bdpSelectCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpSelectCommand1.Connection := Self.BdpConnection1;
Self.bdpSelectCommand1.ParameterCount := (SmallInt(0));
Self.bdpSelectCommand1.SchemaName := nil;
Self.bdpSelectCommand1.Transaction := nil;
Self.bdpSelectCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpInsertCommand1
//
Self.bdpInsertCommand1.CommandOptions := nil;
Self.bdpInsertCommand1.CommandText := nil;
Self.bdpInsertCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpInsertCommand1.Connection := nil;
Self.bdpInsertCommand1.ParameterCount := (SmallInt(0));
Self.bdpInsertCommand1.SchemaName := nil;
Self.bdpInsertCommand1.Transaction := nil;
Self.bdpInsertCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpUpdateCommand1
//
Self.bdpUpdateCommand1.CommandOptions := nil;
Self.bdpUpdateCommand1.CommandText := nil;
Self.bdpUpdateCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpUpdateCommand1.Connection := nil;
Self.bdpUpdateCommand1.ParameterCount := (SmallInt(0));
Self.bdpUpdateCommand1.SchemaName := nil;
Self.bdpUpdateCommand1.Transaction := nil;
Self.bdpUpdateCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpDeleteCommand1
//
Self.bdpDeleteCommand1.CommandOptions := nil;
Self.bdpDeleteCommand1.CommandText := nil;
Self.bdpDeleteCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpDeleteCommand1.Connection := nil;
Self.bdpDeleteCommand1.ParameterCount := (SmallInt(0));
Self.bdpDeleteCommand1.SchemaName := nil;
Self.bdpDeleteCommand1.Transaction := nil;
Self.bdpDeleteCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// BdpDataAdapter1
//
Self.BdpDataAdapter1.DataSet := DataSetPublico;
Self.BdpDataAdapter1.Active := True;
Self.BdpDataAdapter1.DataTable := nil;
Self.BdpDataAdapter1.DeleteCommand := Self.bdpDeleteCommand1;
Self.BdpDataAdapter1.InsertCommand := Self.bdpInsertCommand1;
Self.BdpDataAdapter1.SelectCommand := Self.bdpSelectCommand1;
Self.BdpDataAdapter1.StartRecord := 0;
Self.BdpDataAdapter1.UpdateCommand := Self.bdpUpdateCommand1;
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(80, 104);
Self.Button1.Name := 'Button1';
Self.Button1.TabIndex := 0;
Self.Button1.Text := 'Button1';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
Self.ClientSize := System.Drawing.Size.Create(292, 266);
Self.Controls.Add(Self.Button1);
Self.Name := 'TWinForm';
Self.Text := 'WinForm';
(System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).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;

procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
begin

TWinform1.Create.Show;

end;

end.


unit WinForm1;

interface

uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;

type
TWinForm1 = 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;
procedure TWinForm1_Load(sender: System.Object; e: System.EventArgs);
{$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(TWinForm1))]

implementation

uses WinForm;

{$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 TWinForm1.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(16, 16);
Self.DataGrid1.Name := 'DataGrid1';
Self.DataGrid1.Size := System.Drawing.Size.Create(256, 232);
Self.DataGrid1.TabIndex := 0;
//
// TWinForm1
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
Self.ClientSize := System.Drawing.Size.Create(292, 266);
Self.Controls.Add(Self.DataGrid1);
Self.Name := 'TWinForm1';
Self.Text := 'WinForm1';
Include(Self.Load, Self.TWinForm1_Load);
(System.ComponentModel.ISupportInitialize(Self.DataGrid1)).EndInit;
Self.ResumeLayout(False);
end;
{$ENDREGION}

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

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

procedure TWinForm1.TWinForm1_Load(sender: System.Object; e: System.EventArgs);
begin

DataGrid1.DataSource := DataSetPublico;

end;

end.
Responder Con Cita