全部博文(788)
分类:
2009-02-19 17:03:24
var
s: String;
begin
s := PromptDataSource(Handle, ADOConnection1.ConnectionString);
if CompareText(s, ADOConnection1.ConnectionString) <> 0 then
ADOConnection1.ConnectionString := s;
end;
var
s: String;
begin
s := PromptDataSource(Handle, ADOConnection1.ConnectionString);
if CompareText(s, ADOConnection1.ConnectionString) <> 0 then
begin
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString := s;
ADOConnection1.Connected := True;
end;
end;
如果处于连接状态,ConnectionString比较是不准确的,还是应该先断开连接,修改如下:
var
s: String;
begin
ADOConnection1.Connected := False;
s := PromptDataSource(Handle, ADOConnection1.ConnectionString);
if CompareText(s, ADOConnection1.ConnectionString) <> 0 then
ADOConnection1.ConnectionString := s;
ADOConnection1.Connected := True;
end;
直接传个ADOConnection对象不就完了?如果在多个窗口像这样写那要生成多少个连接?