unit WinForm;

interface

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

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    SqlConnection1: System.Data.SqlClient.SqlConnection;
    sqlSelectCommand1: System.Data.SqlClient.SqlCommand;
    sqlInsertCommand1: System.Data.SqlClient.SqlCommand;
    sqlUpdateCommand1: System.Data.SqlClient.SqlCommand;
    sqlDeleteCommand1: System.Data.SqlClient.SqlCommand;
    SqlDataAdapter1: System.Data.SqlClient.SqlDataAdapter;
    DataSet1: System.Data.DataSet;
    DataGrid1: System.Windows.Forms.DataGrid;
    Button1: System.Windows.Forms.Button;
    Customer: System.Data.DataTable;
    /// <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))]

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;
type
  TArrayOfSystem_Data_DataTable = array of System.Data.DataTable;
begin
  Self.SqlConnection1 := System.Data.SqlClient.SqlConnection.Create;
  Self.sqlSelectCommand1 := System.Data.SqlClient.SqlCommand.Create;
  Self.sqlInsertCommand1 := System.Data.SqlClient.SqlCommand.Create;
  Self.sqlUpdateCommand1 := System.Data.SqlClient.SqlCommand.Create;
  Self.sqlDeleteCommand1 := System.Data.SqlClient.SqlCommand.Create;
  Self.SqlDataAdapter1 := System.Data.SqlClient.SqlDataAdapter.Create;
  Self.DataSet1 := System.Data.DataSet.Create;
  Self.Customer := System.Data.DataTable.Create;
  Self.DataGrid1 := System.Windows.Forms.DataGrid.Create;
  Self.Button1 := System.Windows.Forms.Button.Create;
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).BeginInit;
  (System.ComponentModel.ISupportInitialize(Self.Customer)).BeginInit;
  (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).BeginInit;
  Self.SuspendLayout;
  // 
  // SqlConnection1
  // 
  Self.SqlConnection1.ConnectionString := 'integrated security=SSPI;data sou' +
  'rce=MZQ;persist security info=False;initial catalog=Northwind';
  // 
  // sqlSelectCommand1
  // 
  Self.sqlSelectCommand1.CommandText := 'Select * from Customers';
  Self.sqlSelectCommand1.Connection := Self.SqlConnection1;
  // 
  // SqlDataAdapter1
  // 
  Self.SqlDataAdapter1.DeleteCommand := Self.sqlDeleteCommand1;
  Self.SqlDataAdapter1.InsertCommand := Self.sqlInsertCommand1;
  Self.SqlDataAdapter1.SelectCommand := Self.sqlSelectCommand1;
  Self.SqlDataAdapter1.UpdateCommand := Self.sqlUpdateCommand1;
  // 
  // DataSet1
  // 
  Self.DataSet1.DataSetName := 'NewDataSet';
  Self.DataSet1.Locale := System.Globalization.CultureInfo.Create('zh-CN');
  Self.DataSet1.Tables.AddRange(TArrayOfSystem_Data_DataTable.Create(Self.Customer));
  // 
  // Customer
  // 
  Self.Customer.TableName := 'Table1';
  // 
  // DataGrid1
  // 
  Self.DataGrid1.DataMember := '';
  Self.DataGrid1.DataSource := Self.Customer;
  Self.DataGrid1.HeaderForeColor := System.Drawing.SystemColors.ControlText;
  Self.DataGrid1.Location := System.Drawing.Point.Create(8, 8);
  Self.DataGrid1.Name := 'DataGrid1';
  Self.DataGrid1.Size := System.Drawing.Size.Create(472, 320);
  Self.DataGrid1.TabIndex := 0;
  // 
  // Button1
  // 
  Self.Button1.Location := System.Drawing.Point.Create(216, 352);
  Self.Button1.Name := 'Button1';
  Self.Button1.TabIndex := 1;
  Self.Button1.Text := 'ݿ';
  Include(Self.Button1.Click, Self.Button1_Click);
  // 
  // TWinForm
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(488, 398);
  Self.Controls.Add(Self.Button1);
  Self.Controls.Add(Self.DataGrid1);
  Self.Name := 'TWinForm';
  Self.Text := 'WinForm';
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).EndInit;
  (System.ComponentModel.ISupportInitialize(Self.Customer)).EndInit;
  (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;

  InitializeComponent; //ʼ

end;

procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
  SqlConnection1.Open;                       //
  SqlDataAdapter1.Fill(DataSet1.Tables[0]);   //ʾ
    
end;

end.