关于动态注册SQL Server数据源 (PB代码)
//***********************************************
// 函数名: gf_setodbc_sqlserver
// 功能: 完成sqlserver数据源的注册功能
// 输入参数:
// as_database 数据库名
// as_server 服务器名
// 返回值:
// true 表示自动配置成功
// false 表示自动配置失败
// 设计者: Adamswater
// 完成时间: 2005年6月
//
//***************************************************
boolean lb_rtn
string ls_root,ls_root_dsn
integer li_rtn
string ls_dsnname
lb_rtn = true
ls_root = "HKEY_LOCAL_MACHINE\software\odbc\odbc.ini"
ls_dsnname = as_database + "_DT"//数据源的名字:数据库名字_DT,当然可以修改
ls_root_dsn = ls_root + "\" + ls_dsnname
li_rtn = registryset(ls_root,ls_dsnname,regstring!,"")
if li_rtn= - 1 then
return false
end if
//指定数据库名字
li_rtn = registryset(ls_root_dsn,"Database",regstring!,as_database)
if li_rtn= - 1 then
return false
end if
//指定驱动程序
li_rtn = registryset(ls_root_dsn,"Driver",regstring!,'C:\WINNT\System32\SQLSRV32.dll')
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"LastUser",regstring!,'sa')
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"Server",regstring!,upper(as_server))
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"Trusted_Connection",regstring!,'Yes')
if li_rtn= - 1 then
return false
end if
return lb_rtn
动态注册SQL Server数据源 (PB代码)
最新推荐文章于 2024-07-12 14:26:59 发布