level 4
qq511542629
楼主
想在DBgrid中显示sqlite3数据库,用的AdoConnection和AdoQuery组件,总是不对,代码如下
procedure TForm1.Button1Click(Sender: TObject);
begin
AdoConnection1.Close ;
AdoConnection1.ConnectionString :='Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=SQLite3 Datasource;Database=D:\1.db;StepAPI=0;Timeout=1000"';
AdoConnection1.LoginPrompt :=False;
AdoConnection1.Open;
if AdoConnection1.Connected=True then
begin
showmessage('连接成功'); //已经显示连接成功了!!!
AdoQuery1.Connection :=AdoConnection1;
Dbgrid1.DataSource :=AdoQuery1.DataSource;
AdoQuery1.Close;
AdoQuery1.SQL.Clear ;
AdoQuery1.SQL.Add('select * from table1');
AdoQuery1.Open; //好像运行到这句就会出错!!!!!!!!!
end;

2016年10月21日 01点10分
1
procedure TForm1.Button1Click(Sender: TObject);
begin
AdoConnection1.Close ;
AdoConnection1.ConnectionString :='Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=SQLite3 Datasource;Database=D:\1.db;StepAPI=0;Timeout=1000"';
AdoConnection1.LoginPrompt :=False;
AdoConnection1.Open;
if AdoConnection1.Connected=True then
begin
showmessage('连接成功'); //已经显示连接成功了!!!
AdoQuery1.Connection :=AdoConnection1;
Dbgrid1.DataSource :=AdoQuery1.DataSource;
AdoQuery1.Close;
AdoQuery1.SQL.Clear ;
AdoQuery1.SQL.Add('select * from table1');
AdoQuery1.Open; //好像运行到这句就会出错!!!!!!!!!
end;


