我用的是F1book6.1,Delphi 6, 连接数据库db2.mdb,如果你需要的话,给你寄个例子,
另外F1book安装后有不少关于ODBC的VB例子,看一下代码,应该不是很难.
unit fmF1ODBCDemo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AxCtrls, OleCtrls, TTF160_TLB, StdCtrls;
type
TForm1 = class(TForm)
fbook1: TF1Book6;
btnConnect: TButton;
btnDisconn: TButton;
Button1: TButton;
procedure btnConnectClick(Sender: TObject);
procedure btnDisconnClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure QueryTable(strSQL : widestring);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnConnectClick(Sender: TObject);
var
Connstr : widestring;
RetCode : smallint;
begin
ConnStr := 'DSN=F1ODBCDemo;DBQ=' + ExtractFilePath(Application.ExeName) +
'/db2.mdb;DriverId=25;FIL=MS';
try
fbook1.ODBCConnect(ConnStr,True,RetCode);
except
Showmessage('Connect DataBase failed!');
end;
end;
procedure TForm1.btnDisconnClick(Sender: TObject);
begin
fbook1.ODBCDisconnect;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
strSQL : widestring;
begin
fbook1.Sheet := 1;
strSQL := 'Select * from Employee_Table';
QueryTable(strSQL);
end;
procedure TForm1.QueryTable(strSQL: widestring);
var
bForceShowDlg, bSetColNames,bSetColFormats, bSetColWidths,bSetMaxRC : wordbool;
RetCode : smallint;
begin
bForceShowDlg := False;
bSetColNames := True;
bSetColFormats := True;
bSetColWidths := True;
bSetMaxRC := True;
screen.Cursor := crHourGlass;
try
fbook1.ODBCQuery(strSQL,1,1,bForceShowDlg,bSetColNames,bSetColFormats,
bSetColWidths,bSetMaxRC,RetCode);
except
ShowMessage(fbook1.ODBCErrorMsg);
end;
screen.Cursor := crDefault;
end;
end.