我使用动态参数连接的时候为什么说错误的呢?我跟前面的设置方法一样的啊?在调试的时候给出错误,我在调试的时候还没有写其他的窗口代码?那个告述我是什么原因?谢谢!
unit Uregister;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,inifiles, ExtCtrls;
type
TFregister = class(TForm)
Image1: TImage;
EWMIS_ServerName: TEdit;
EWMIS_loginName: TEdit;
EWMIS_PWD: TEdit;
EWMIS_DbsName: TEdit;
EYH_ServerName: TEdit;
EYH_loginName: TEdit;
EYH_PWD: TEdit;
EYH_DbsName: TEdit;
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
Panel2: TPanel;
Button3: TButton;
Button5: TButton;
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure EWMIS_ServerNameChange(Sender: TObject);
procedure EWMIS_loginNameChange(Sender: TObject);
procedure EWMIS_PWDChange(Sender: TObject);
procedure EWMIS_DbsNameChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Fregister: TFregister;
implementation
uses dataMU, ClassesU;
{$R *.dfm}
procedure TFregister.FormShow(Sender: TObject);
Var
myinifile:Tinifile;
begin
myinifile:=Tinifile.create(ExtractFilepath(paramstr(0))+'WmisYH.ini');
EWMIS_ServerName.text := myinifile.ReadString('县级登录参数','服务器名','(local)');
EWMIS_LoginName.text := myinifile.ReadString('县级登录参数','用户名','sa');
EWMIS_PWD.text := myinifile.ReadString('县级登录参数','密码','');
EWMIS_DbsName.text := myinifile.ReadString('县级登录参数','数据库名','pis_base_xj');
EYH_ServerName.text := myinifile.ReadString('业务登录参数','服务器名','(local)');
EYH_LoginName.text := myinifile.ReadString('业务登录参数','用户名','sa');
EYH_PWD.text := myinifile.ReadString('业务登录参数','密码','');
EYH_DbsName.text := myinifile.ReadString('业务登录参数','数据库名','pis_base_YH') ;
end;
procedure TFregister.BitBtn1Click(Sender: TObject);
Var
myinifile:Tinifile;
begin
myinifile:=Tinifile.create(ExtractFilepath(paramstr(0))+'WmisYH.ini');
myinifile.WriteString('县级登录参数','服务器名',EWMIS_ServerName.text);
myinifile.WriteString('县级登录参数','用户名',EWMIS_LoginName.text);
myinifile.WriteString('县级登录参数','密码',EWMIS_PWD.text);
myinifile.WriteString('县级登录参数','数据库名',EWMIS_DbsName.text);
myinifile.WriteString('业务登录参数','服务器名',EYH_ServerName.text);
myinifile.WriteString('业务登录参数','用户名',EYH_LoginName.text);
myinifile.WriteString('业务登录参数','密码',EYH_PWD.text);
myinifile.WriteString('业务登录参数','数据库名',EYH_DbsName.text) ;
end;
procedure TFregister.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TFregister.Button1Click(Sender: TObject);
Var
WMISconnstring:string;
begin
WMISconnstring:='Provider=SQLOLEDB.1;Password=' + EWMIS_PWD.Text +
';Persist Security Info=True;User ID=' + EWMIS_loginName.Text +
';Initial Catalog=' + EWMIS_DbsName.Text + ';Data Source=' + EWMIS_ServerName.Text ;
DataM.ADOConn_base.ConnectionString:=WMISconnstring;
try
datam.ADOConn_base.Connected:=true;
MessageBox(Handle, 'PIS基础数据库连接成功!', '信息', MB_ICONASTERISK);
Button3.Enabled:=true;
except
MessageBox(Handle, 'PIS基础数据库连接失败!', '信息', MB_ICONASTERISK);
Button3.Enabled:=false;
end;
end;
procedure TFregister.Button2Click(Sender: TObject);
Var
YHconnstring:string;
begin
YHconnstring:='Provider=SQLOLEDB.1;Password=' + EYH_PWD.Text+
';Persist Security Info=True;User ID=' + EYH_loginName.Text +
';Initial Catalog=' + EYH_DbsName.Text + ';Data Source=' + EYH_ServerName.Text ;
dataM.ADOCONn_YH.ConnectionString:=YHconnstring;
try
dataM.ADOCONn_YH.Connected:=true;
MessageBox(Handle, '业务数据库连接成功!', '信息', MB_ICONASTERISK);
Button5.Enabled:=true;
except
MessageBox(Handle, '业务数据库连接失败!', '信息', MB_ICONASTERISK);
Button5.Enabled:=false;
end;
end;
procedure TFregister.Button3Click(Sender: TObject);
Var
myinifile:Tinifile;
begin
myinifile:=Tinifile.create(ExtractFilepath(paramstr(0))+'WmisYH.ini');
myinifile.WriteString('县级登录参数','服务器名',EWMIS_ServerName.text);
myinifile.WriteString('县级登录参数','用户名',EWMIS_LoginName.text);
myinifile.WriteString('县级登录参数','密码',EWMIS_PWD.text);
myinifile.WriteString('县级登录参数','数据库名',EWMIS_DbsName.text);
myinifile.Destroy;
end;
procedure TFregister.Button5Click(Sender: TObject);
Var
myinifile:Tinifile;
begin
myinifile:=Tinifile.create(ExtractFilepath(paramstr(0))+'WmisYH.ini');
myinifile.WriteString('业务登录参数','用户名',EYH_LoginName.text);
myinifile.WriteString('业务登录参数','密码',EYH_PWD.text);
myinifile.WriteString('业务登录参数','数据库名',EYH_DbsName.text) ;
myinifile.Destroy;
end;
procedure TFregister.EWMIS_ServerNameChange(Sender: TObject);
begin
datam.ADOConn_base.Connected:=false;
end;
procedure TFregister.EWMIS_loginNameChange(Sender: TObject);
begin
datam.ADOConn_base.Connected:=false;
end;
procedure TFregister.EWMIS_PWDChange(Sender: TObject);
begin
datam.ADOConn_base.Connected:=false;
end;
procedure TFregister.EWMIS_DbsNameChange(Sender: TObject);
begin
datam.ADOConn_base.Connected:=false;
end;
end.