数据库连接的问题? 其实是不用的,因为ADO是一次连接,到处运行的,你只要在编程的时候在你的客户端程序设好你的服务器端,这样你的客户端每次登录的时候就会找到你的服务器的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果你的服务器会变,可能你得动态生成TADOConnection.ConnectionString了.我的做法一般是把配置信息,例如服务器名、用户名、口令(加密)和初始数据库都放在INI文件里,然后要用的时候再从里面读取来生成Connectionstring。procedure SetConnectionString(ServerName, UserName, Password, InitDB: string); var SYSINI: TINIFile; tmpstr: string; begin SYSINI := TIniFile.Create('DB.INI'); try with SYSINI do begin WriteString('Database', 'ServerName', ServerName); WriteString('Database', 'UserName', UserName); WriteString('Database', 'InitDB', InitDB); tmpstr := Encrypt(Password, Key); WriteString('Database', 'Password', tmpstr); end; finally SYSINI.Free; end; end; function GetConnectionString: string; var SYSINI: TINIFile; ServerName, UserName, Password, InitDB: string; tmpstr: string; begin SYSINI := TIniFile.Create('DB.INI'); try ServerName := SYSINI.ReadString('Database', 'ServerName', ''); UserName := SYSINI.ReadString('Database', 'UserName', ''); InitDB := SYSINI.ReadString('Database', 'InitDB', ''); tmpstr := SYSINI.ReadString('Database', 'Password', ''); Password := Decrypt(tmpstr, Key); Result := ''; Result := 'Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + UserName + ';Initial Catalog=' + InitDB + ';Data Source=' + ServerName; finally SYSINI.Free; end; end; 如果你的服务器会变,可能你得动态生成TADOConnection.ConnectionString了.我的做法一般是把配置信息,例如服务器名、用户名、口令(加密)和初始数据库都放在INI文件里,然后要用的时候再从里面读取来生成Connectionstring。procedure SetConnectionString(ServerName, UserName, Password, InitDB: string); var SYSINI: TINIFile; tmpstr: string; begin SYSINI := TIniFile.Create('DB.INI'); try with SYSINI do begin WriteString('Database', 'ServerName', ServerName); WriteString('Database', 'UserName', UserName); WriteString('Database', 'InitDB', InitDB); tmpstr := Encrypt(Password, Key); WriteString('Database', 'Password', tmpstr); end; finally SYSINI.Free; end; end; function GetConnectionString: string; var SYSINI: TINIFile; ServerName, UserName, Password, InitDB: string; tmpstr: string; begin SYSINI := TIniFile.Create('DB.INI'); try ServerName := SYSINI.ReadString('Database', 'ServerName', ''); UserName := SYSINI.ReadString('Database', 'UserName', ''); InitDB := SYSINI.ReadString('Database', 'InitDB', ''); tmpstr := SYSINI.ReadString('Database', 'Password', ''); Password := Decrypt(tmpstr, Key); Result := ''; Result := 'Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + UserName + ';Initial Catalog=' + InitDB + ';Data Source=' + ServerName; finally SYSINI.Free; end; end; 你只要知道你的 服务器的ip即可,这样client 连接到sql server 即可。发送数据有很多办法,savetofilebcp批量复制! 缓存问题急,谢谢大家! 郁闷,TTreeView 的ImageIndex问题 一个奇弱无比的问题!?(只需30秒) 请问如何让窗口全屏 哪里有 FastReport 的下载!! CSDN的一个BUG 请问如何遍历获得一个Grid某列某行的数值? python , hello world 不成功。 为什么??? z_x_b,送给我吧 SQL语句求助! 请教高手:如何实现网络蚂蚁中的代理服务器的设置功能?不够再加. 100分:哪里有的delphi 书下载(delphi 6 developer's guide、Mastering delphi、delphi unshealed)
procedure SetConnectionString(ServerName, UserName, Password, InitDB: string);
var
SYSINI: TINIFile;
tmpstr: string;
begin
SYSINI := TIniFile.Create('DB.INI');
try
with SYSINI do
begin
WriteString('Database', 'ServerName', ServerName);
WriteString('Database', 'UserName', UserName);
WriteString('Database', 'InitDB', InitDB);
tmpstr := Encrypt(Password, Key);
WriteString('Database', 'Password', tmpstr);
end;
finally
SYSINI.Free;
end;
end;
function GetConnectionString: string;
var
SYSINI: TINIFile;
ServerName, UserName, Password, InitDB: string;
tmpstr: string;
begin
SYSINI := TIniFile.Create('DB.INI');
try
ServerName := SYSINI.ReadString('Database', 'ServerName', '');
UserName := SYSINI.ReadString('Database', 'UserName', '');
InitDB := SYSINI.ReadString('Database', 'InitDB', '');
tmpstr := SYSINI.ReadString('Database', 'Password', '');
Password := Decrypt(tmpstr, Key);
Result := '';
Result := 'Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + UserName + ';Initial Catalog=' + InitDB + ';Data Source=' + ServerName;
finally
SYSINI.Free;
end;
end;
procedure SetConnectionString(ServerName, UserName, Password, InitDB: string);
var
SYSINI: TINIFile;
tmpstr: string;
begin
SYSINI := TIniFile.Create('DB.INI');
try
with SYSINI do
begin
WriteString('Database', 'ServerName', ServerName);
WriteString('Database', 'UserName', UserName);
WriteString('Database', 'InitDB', InitDB);
tmpstr := Encrypt(Password, Key);
WriteString('Database', 'Password', tmpstr);
end;
finally
SYSINI.Free;
end;
end;
function GetConnectionString: string;
var
SYSINI: TINIFile;
ServerName, UserName, Password, InitDB: string;
tmpstr: string;
begin
SYSINI := TIniFile.Create('DB.INI');
try
ServerName := SYSINI.ReadString('Database', 'ServerName', '');
UserName := SYSINI.ReadString('Database', 'UserName', '');
InitDB := SYSINI.ReadString('Database', 'InitDB', '');
tmpstr := SYSINI.ReadString('Database', 'Password', '');
Password := Decrypt(tmpstr, Key);
Result := '';
Result := 'Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + UserName + ';Initial Catalog=' + InitDB + ';Data Source=' + ServerName;
finally
SYSINI.Free;
end;
end;
这样client 连接到sql server 即可。
发送数据有很多办法,
savetofile
bcp批量复制!