procedure TFormServerSelect.GetDatabasesLsit(FDatabasesLsit:TStrings); var SQLServer, DBList: Variant; i, iDatabasesCount: Integer; begin if not CurrAutoConfigurationSqlServerParams then exit; if FDatabasesLsit=nil then FDatabasesLsit:=cbxDataBases.Items; FDatabasesLsit.Clear; try SQLServer := CreateOleObject('SQLDMO.SQLServer'); SQLServer.LoginSecure := cbxLoginSecure.Checked; SQLServer.LoginTimeout := 15;// 设定超时时间 SQLServer.Connect(edtServerName.Text,edtUserName.Text,edtUserPassword.Text); DBList := SQLServer.Databases; iDatabasesCount := DBList.Count; for i := 1 to iDatabasesCount do FDatabasesLsit.Add(DBList.Item(i).Name); SQLServer := NULL; DBList := NULL; Application.MessageBox('连接成功,您现在可以从数据库列表中选择存在的数据!','信息提示',MB_OK+MB_ICONINFORMATION); except Application.MessageBox('当前服务器登录失败,用户名或口令输入错误,请重新输入!','信息提示',MB_OK+MB_ICONINFORMATION); end; end;
procedure TFormServerSelect.GetDatabasesLsit(FDatabasesLsit:TStrings); var SQLServer, DBList: Variant; i, iDatabasesCount: Integer; begin if not CurrAutoConfigurationSqlServerParams then exit; if FDatabasesLsit=nil then FDatabasesLsit:=cbxDataBases.Items; FDatabasesLsit.Clear; try SQLServer := CreateOleObject('SQLDMO.SQLServer'); SQLServer.LoginSecure := cbxLoginSecure.Checked; SQLServer.LoginTimeout := 15;// 设定超时时间 SQLServer.Connect(edtServerName.Text,edtUserName.Text,edtUserPassword.Text); DBList := SQLServer.Databases; iDatabasesCount := DBList.Count; for i := 1 to iDatabasesCount do FDatabasesLsit.Add(DBList.Item(i).Name); SQLServer := NULL; DBList := NULL; Application.MessageBox('连接成功,您现在可以从数据库列表中选择存在的数据!','信息提示',MB_OK+MB_ICONINFORMATION); except Application.MessageBox('当前服务器登录失败,用户名或口令输入错误,请重新输入!','信息提示',MB_OK+MB_ICONINFORMATION); end; end;
2005-6-21 15:38:56
|