需要在SQLite中存储一些数据。要使用SQLite选择了UniDac,但是有一个问题:在UniConnection中,在"数据库"字段中,我选择SQLite并输入数据库的名称 - 收到错误"不支持的元数据种类"。未创建数据库文件。问题出在哪里?与之前与UniDac合作一样,因此没有观察到此类问题。
UniDAC 4.1.6 with Delphi XE2 我没有看到任何问题。 SQLite3.dll 必须位于系统路径或可执行文件所在的目录中。 下面的非常基本的示例在单击btnConnect时创建数据文件。
unit uMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, UniProvider,
SQLiteUniProvider, Data.DB, MemDS, DBAccess, Uni, Vcl.ExtCtrls, Vcl.DBCtrls,
Vcl.StdCtrls;
type
TfrmMain = class(TForm)
UniDataSource1: TUniDataSource;
UniConnection1: TUniConnection;
UniQuery1: TUniQuery;
SQLiteUniProvider1: TSQLiteUniProvider;
DBGrid1: TDBGrid;
edtDBName: TEdit;
Label1: TLabel;
DBNavigator1: TDBNavigator;
btnConnect: TButton;
procedure btnConnectClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.btnConnectClick(Sender: TObject);
begin
if (btnConnect.Caption = 'Connect') then
begin
UniConnection1.ProviderName := 'SQLite';
UniConnection1.Database := ExtractFilePath(Application.ExeName)
+ edtDBName.Text;
UniConnection1.Connect;
btnConnect.Caption := 'Disconnect';
end
else
begin
UniConnection1.Disconnect;
btnConnect.Caption := 'Connect';
end;
end;