procedure TInsert.FormCreate(Sender: TObject); var i:integer; begin ADOQuery2.Connection:=ADOConnection1; ADOQuery2.Close; ADOQuery2.SQL.Clear; ADOQuery2.SQL.Add('SELECT component '); ADOQuery2.SQL.Add('From parts '); ADOQuery2.Open; For i:=0 to ADOQuery2.RecordCount-1 do begin parts.Items.Add(ADOQuery2.FieldValues['component']); ADOQuery2.Next; end;end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, RzPopups, StdCtrls, Mask, RzEdit,
RzLabel, ExtCtrls, RzPanel, RzCmboBx, ComCtrls, RzButton;type
TInsert = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
RzGroupBox1: TRzGroupBox;
RzLabel1: TRzLabel;
RzEdit1: TRzEdit;
RzEdit2: TRzEdit;
RzLabel2: TRzLabel;
RzLabel3: TRzLabel;
DateTimePicker1: TDateTimePicker;
RzLabel4: TRzLabel;
RzComboBox1: TRzComboBox;
RzLabel5: TRzLabel;
RzComboBox2: TRzComboBox;
RzLabel6: TRzLabel;
RzComboBox3: TRzComboBox;
RzLabel7: TRzLabel;
RzComboBox4: TRzComboBox;
RzLabel8: TRzLabel;
RzComboBox5: TRzComboBox;
RzComboBox6: TRzComboBox;
RzLabel9: TRzLabel;
RzButton1: TRzButton;
RzButton2: TRzButton;
RzLabel10: TRzLabel;
DataSource2: TDataSource;
ADOQuery2: TADOQuery;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Insert: TInsert;implementation{$R *.dfm}procedure TInsert.FormCreate(Sender: TObject);
begin
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select * from parts');
ADOQuery2.Open;
RzComboBox5.Items.Clear;
while not(ADOQuery2.Eof) do
begin
RzComboBox5.Items.Add(ADOQuery2.FieldByName('component').AsString);
ADOQuery2.Next;
end;
RzEdit1.Text:='';
RzEdit1.SetFocus;end;
表为 parts
字段为 component编译通过不了,出现如下错误信息:[Error] Unit2.pas(78): Declaration expected but end of file found[Fatal Error] Project2.dpr(6): Could not compile used unit 'Unit2.pas'
var
i:integer;
begin
ADOQuery2.Connection:=ADOConnection1;
ADOQuery2.Close;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('SELECT component ');
ADOQuery2.SQL.Add('From parts '); ADOQuery2.Open;
For i:=0 to ADOQuery2.RecordCount-1 do
begin
parts.Items.Add(ADOQuery2.FieldValues['component']);
ADOQuery2.Next;
end;end;