诸位大侠: 我想在客户的机器上创建sql 数据库别名( 单机环境)参数如下:===============================================================================================
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=lz;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CWB;Use Encryption for Data=False;Tag with column collation when possible=False
=============================================================================================== 以前我用语句创建access 数据库别名的语句如下:(现在创建sql 数据别名也想参照这个格式):===============================================================GetWindowsDirectory(buffer, SizeOf(buffer));
r:=tregistry.create;
with r do
begin
rootkey:=hkey_local_machine;
if openkey('software\odbc\odbc.ini\odbc data sources',true) then
begin
writestring('lz','Microsoft Access Driver (*.mdb)');
end;
closekey;
if openkey('software\odbc\odbc.ini\ggmt',true) then
begin
writestring('DBQ',strAppPath+'data\dir');
writestring('DRIVER',buffer+'\system\odbcjt32.dll');
WriteInteger('DriverId',25);
writestring('FIL','ms access');
WriteInteger('SafeTransactions',0);
end;
if openkey('engines\jet',true) then
begin
writestring('ImplicitCommitSync','');
WriteInteger('MaxBufferSize',2048);
WriteInteger('PageTimeout',5);
WriteInteger('Threads',3);
writestring('UserCommitSync','yes');
end;
closekey;
free;
end; ==========================================
大侠们,谢了
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=lz;Data Source=.;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=CWB;Use Encryption for Data=False;Tag with column collation when possible=False
=============================================================================================== 以前我用语句创建access 数据库别名的语句如下:(现在创建sql 数据别名也想参照这个格式):===============================================================GetWindowsDirectory(buffer, SizeOf(buffer));
r:=tregistry.create;
with r do
begin
rootkey:=hkey_local_machine;
if openkey('software\odbc\odbc.ini\odbc data sources',true) then
begin
writestring('lz','Microsoft Access Driver (*.mdb)');
end;
closekey;
if openkey('software\odbc\odbc.ini\ggmt',true) then
begin
writestring('DBQ',strAppPath+'data\dir');
writestring('DRIVER',buffer+'\system\odbcjt32.dll');
WriteInteger('DriverId',25);
writestring('FIL','ms access');
WriteInteger('SafeTransactions',0);
end;
if openkey('engines\jet',true) then
begin
writestring('ImplicitCommitSync','');
WriteInteger('MaxBufferSize',2048);
WriteInteger('PageTimeout',5);
WriteInteger('Threads',3);
writestring('UserCommitSync','yes');
end;
closekey;
free;
end; ==========================================
大侠们,谢了
解决方案 »
- xml 转换 excel问题
- 数组的容量
- 项目文件从Delphi5升级到Delphi6时的问题
- 几种常用开发工具的比较(delphi得分很高,哈哈,意淫一把)
- 怎么样在stringgird中的cell中插入一个speedbutton?
- 求助!!系统消息的一些问题!
- 关于在listView里按shift和ctrl时选择itme时的问题,在线等待,100分。
- delphi6 编译的EXE调用BAT文件报错,求指导!!!!!!
- cobi:什么叫端口,最快,最通俗,最容易理解的解释,给你26+1分!
- 怎样知道当前可执行文件所在路径,即程序文件所在路径
- 怪事!!recv的时候,写入buffer的数据少于recv返回的字节数,甚至buffer是空的!!!!
- 如何解决改变DGGridEh中的值,数据库的数据也会跟着改变的。
既然是sqlserver,何必用别名呢,直接用OLE连接不简单吗?
var
MachineName: string;
begin
if DBKind='ACCESS' then // ACCESS 库
Result := 'Provider=Microsoft.JET.OLEDB.4.0;'+
'Persist Security Info=True;Mode=Share Deny None;'+
'Data Source='+_DIR_APP+DBName+'.mdb;'+
'User ID=Admin; Jet OLEDB:Database Password='+_ACCESS_PSW
else begin
if Copy(_IP_ADDRESS,1,3) = '127' then
GetNameByIPAddr(_IP_ADDRESS,MachineName) // 转换为机器名访问SQL SERVER 服务器
else
MachineName := _IP_ADDRESS; // 由于单机下访问 SQL SERVER 服务器失败,故做转换
Result := 'Provider=SQLOLEDB.1;'+
'Persist Security Info=True;' +
'Initial Catalog=' + DBName + ';'+
'Data Source=' + MachineName + ';'+
'User ID=' + _LOGIN_USER + '; PASSWORD=' + _LOGIN_PSW
end;
end;function GetNameByIPAddr(IPAddr: string;var MacName: string): boolean;
var
SockAddrIn: TSockAddrIn;
HostEnt: PHostEnt;
WSAData: TWSAData;
begin
Result := False;
if IpAddr = '' then exit;
try
WSAStartup(2, WSAData);
SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr));
HostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
if HostEnt <> nil then MacName := StrPas(Hostent^.h_name);
Result := True;
finally
WSACleanup;
end;
end;
r:=tregistry.create;
with r do
begin
rootkey:=hkey_local_machine;
if openkey('software\odbc\odbc.ini\odbc data sources',true) then
begin
writestring('lz','Microsoft Access Driver (*.mdb)');
end;
closekey;
if openkey('software\odbc\odbc.ini\CWB',true) then
begin
writestring('DataBase','lz');
writestring('DRIVER','C:\WINDOWS\system32\sqlsrv32.dll');
WriteInteger('LastUser','sa');
writestring('Server','(local)');end;closekey;
free;
end;
try it again.