给段代码你领会一下精神,记得给分.
procedure TForm1.FormCreate(Sender: TObject);//数据库连接代码
begin
AConnection:=createoleobject('ADODB.Connection');
AConnection.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;Persist Security Info=False');
end;
procedure TForm1.Button1Click(Sender: TObject);//数据库表列举
var i:Integer;
begin
i := 0;
ARecordSet:=CreateOleObject('ADODB.RecordSet');
ARecordSet.open( 'Select * from userinfo',AConnection,3,3);
StringGrid1.RowCount := ARecordSet.RecordCount+1;
StringGrid1.ColCount := 2;
while not ARecordSet.eofdo
begin
StringGrid1.Cells[0,i]:= ARecordSet.Fields['name'].Value;
StringGrid1.Cells[1,i]:= ARecordSet.Fields['pass'].Value;
i := i+1;
ARecordSet.movenext;
end;
//表1普通用户表的列举
ARecordSet:=CreateOleObject('ADODB.RecordSet');
ARecordSet.open( 'Select * from userinfo',AConnection,3,3);
StringGrid1.RowCount := ARecordSet.RecordCount+1;
StringGrid1.ColCount := 2;
while not ARecordSet.eofdo
begin
StringGrid1.Cells[0,i]:= ARecordSet.Fields['name'].Value;
StringGrid1.Cells[1,i]:= ARecordSet.Fields['pass'].Value;
i := i+1;
ARecordSet.movenext;
end;
//表2VIP会员表的列举
ARecordSet:=CreateOleObject('ADODB.RecordSet');
ARecordSet.open( 'Select * from Vipuserinfo',AConnection,3,3);
StringGrid1.RowCount := ARecordSet.RecordCount+1;
StringGrid1.ColCount := 2;
while not ARecordSet.eofdo
begin
StringGrid1.Cells[0,i]:= ARecordSet.Fields['name'].Value;
StringGrid1.Cells[1,i]:= ARecordSet.Fields['pass'].Value;
i := i+1;
ARecordSet.movenext;
end;
end;