用程序如何判断一个指定IP(如:192.168.0.1)上的SQLserver服务是否开启? 如题。请高人赐教...... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用这样的方法捕获错误try ADOConnection.Connected:=True;except //在这里捕获end 【转贴】//定义个读取连接配置的函数从fonfig.ini文件中读取数据库连接配置;function GetConnectionString(aType, aUser, aPwd, aDataBase, aServer: string): string;begin Result := ''; if aType = 'ACCESS' then begin Result := 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;'; Result := Result + 'Data Source=' + aDataBase; end; if aType = 'SQL' then begin Result := 'Provider=SQLOLEDB.1;Persist Security Info=False;'; Result := Result + 'User ID=' + aUser + ';'; Result := Result + 'Password=' + aPwd + ';'; Result := Result + 'Initial Catalog=' + aDataBase + ';'; Result := Result + 'Data Source=' + aServer; end; if aType = 'ODBC' then begin Result := 'Provider=MSDASQL.1;Persist Security Info=False;'; Result := Result + 'Data Source=' + aServer + ';'; Result := Result + 'Initial Catalog=' + aDataBase; end;end;procedure TPasswordDlg.FormCreate(Sender: TObject);var IniFile: TIniFile; FUser,FPwd,FServer,FDataBase:string;begin IniFile :=Tinifile.Create( ExtractFilePath(Paramstr(0))+'config.ini'); try FUser := IniFile.ReadString('Current Setting', 'User', ''); FPwd := DecodeString(IniFile.ReadString('Current Setting', 'Pwd', '')); FServer := IniFile.ReadString('Current Setting', 'Server', ''); FDataBase := IniFile.ReadString('Current Setting', 'DataBase', ''); ADOConnection1.Connected := False; ADOConnection1.ConnectionString :=GetConnectionString('SQL', FUser, FPwd, FDataBase, FServer); finally IniFile.Free; end; times:=0end;//以下为config.ini文件的内容;[Current Setting]User=saPwd=eml5dWhlYmk=Server=10.10.242.1DataBase=shuini 使用DELPHI如何向图片中写字? 如何提取Delphi编译环境? ComboBox的使用 ★★★★★★★★急!急!有点难度的问题:如何获得DBGridEh网格中正在编辑的字段值★★★★★★★★ Pchar Lpctstr Pansichar 内存分配 dbtree的小问题 关于报表制作的问题 dbgrid土问题,立即给分 因资金严重匮乏,想找点生意来做! 初学者问题,关于流行的编程概念问题。 开机关机的消息如何获得阿? 兄弟这个资源好像有问题,不信你试试. 就是不知道哪里有问题.
try
ADOConnection.Connected:=True;
except
//在这里捕获
end
//定义个读取连接配置的函数从fonfig.ini文件中读取数据库连接配置;
function GetConnectionString(aType, aUser, aPwd, aDataBase,
aServer: string): string;
begin
Result := '';
if aType = 'ACCESS' then
begin
Result := 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;';
Result := Result + 'Data Source=' + aDataBase;
end;
if aType = 'SQL' then
begin
Result := 'Provider=SQLOLEDB.1;Persist Security Info=False;';
Result := Result + 'User ID=' + aUser + ';';
Result := Result + 'Password=' + aPwd + ';';
Result := Result + 'Initial Catalog=' + aDataBase + ';';
Result := Result + 'Data Source=' + aServer;
end;
if aType = 'ODBC' then
begin
Result := 'Provider=MSDASQL.1;Persist Security Info=False;';
Result := Result + 'Data Source=' + aServer + ';';
Result := Result + 'Initial Catalog=' + aDataBase;
end;
end;procedure TPasswordDlg.FormCreate(Sender: TObject);var
IniFile: TIniFile;
FUser,FPwd,FServer,FDataBase:string;
begin
IniFile :=Tinifile.Create( ExtractFilePath(Paramstr(0))+'config.ini');
try
FUser := IniFile.ReadString('Current Setting', 'User', '');
FPwd := DecodeString(IniFile.ReadString('Current Setting', 'Pwd', ''));
FServer := IniFile.ReadString('Current Setting', 'Server', '');
FDataBase := IniFile.ReadString('Current Setting', 'DataBase', '');
ADOConnection1.Connected := False;
ADOConnection1.ConnectionString :=GetConnectionString('SQL', FUser, FPwd,
FDataBase, FServer);
finally
IniFile.Free;
end;
times:=0
end;//以下为config.ini文件的内容;
[Current Setting]
User=sa
Pwd=eml5dWhlYmk=
Server=10.10.242.1
DataBase=shuini