我单独建了一个项目,就只有这两个函数,但是还是这样。下面这个项目,两个button,先点击Button1,得到calXY的结果;再点击Button2,打开adoconnection连接,然后在点击Button1,calXY的结果就不一样了。很奇怪啊,怎么adoconnection连接会影响到系统计算精度的?如果adoconnection连接的是sql server数据库就不会这样。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x , y : Extended;
a1,b1,a2,b2 : Extended;
A1X, A1Y,A2X, A2Y, B1X, B1Y, B2X, B2Y: Extended;
begin
A1X:=634874.161052602;
A1Y:=3159389.92453509;
A2X:=634874.161052601;
A2Y:=3159446.38660127;
B1X:=634874.128055474;
B1Y:=3159418.19057566;
B2X:=634953.939854369;
B2Y:=3159407.46828426;
a1 := (A1Y-A2Y)/(A1X-A2X);
b1 := (A2Y*A1X-A1Y*A2X)/(A1X-A2X);
a2 := (B1Y-B2Y)/(B1X-B2X);
b2 := (B2Y*B1X-B1Y*B2X)/(B1X-B2X);
x := (b2-b1)/(a1-a2);
y := a1*x+b1;
edit1.Text := floattostr(x);
edit2.Text := floattostr
;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ADOConnection1 do
begin
try
Connected := false;
ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+'e:/myacc.mdb'+';Persist Security Info=False;';
Connected := true;
except
end;
end;
end;
end.