需要在SQLite中存储一些数据。使用SQLite选择了UniDac,但是有一个问题:当在UniConnection中,在“数据库”字段中,我选择SQLite并输入数据库的名称 - 得到错误“不支持的元数据类型”。未创建数据库文件。问题是什么?正如之前与UniDac合作过的那样,没有观察到这些问题。
答案 0 :(得分:2)
UniDAC 4.1.6与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;