我在窗體創建時使打開數據表﹐否則連接數據庫 代碼如下﹕
但結果出現數據登錄框﹐然后提示'datasource name not found and no default driver specified"后才出現連接數據庫的東東﹐之后正常 可用
請幫助查一下了代碼如下﹕procedure TForm1.FormCreate(Sender: TObject);begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from person');
adoquery1.Connection:=adoconnection1;
datasource1.DataSet:=adoquery1;
dbgrid1.DataSource:=datasource1;
try
adoquery1.Active:=true;
except
begin
adoquery1.Close;
adoconnection1.Connected:=false;
adoconnection1.ConnectionString:=promptdatasource(handle,adoconnection1.ConnectionString);
adoconnection1.LoginPrompt:=false;
adoconnection1.Connected:=true;
adoquery1.Active:=true;
end;
end;end;
但結果出現數據登錄框﹐然后提示'datasource name not found and no default driver specified"后才出現連接數據庫的東東﹐之后正常 可用
請幫助查一下了代碼如下﹕procedure TForm1.FormCreate(Sender: TObject);begin
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add('select * from person');
adoquery1.Connection:=adoconnection1;
datasource1.DataSet:=adoquery1;
dbgrid1.DataSource:=datasource1;
try
adoquery1.Active:=true;
except
begin
adoquery1.Close;
adoconnection1.Connected:=false;
adoconnection1.ConnectionString:=promptdatasource(handle,adoconnection1.ConnectionString);
adoconnection1.LoginPrompt:=false;
adoconnection1.Connected:=true;
adoquery1.Active:=true;
end;
end;end;
adoconnection1.ConnectionString:='';直接写字符串
不要见怪