导航
  • 主页
  • API 调用
  • 基础类
  • 控件与界面
  • 数据库相关
  • DataWindow
  • 项目管理
  • Web 应用
  • 脚本语言

一个最基本的问题

leiming 2003-12-12 10:13:31
程序做完、打包。但是我用的ODBC,怎么在目标机器中脱离PB环境安装执行?
...全文
23 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bunnysky 2003-12-12
UP
回复
mfjun007 2003-12-12
详细。顶一下
回复
liliang800207 2003-12-12
shide
回复
chrisfy 2003-12-12
搜索,同样的帖子很多
回复
dotnba 2003-12-12
// [PUBLIC] Function f_set_odbc in f_set_odbc ( string s_dsn, string db_name ) returns integer
//--------------------------------------------------------------------
// Description:通过给定的名称和数据库文件名注册ODBC
//--------------------------------------------------------------------
// Arguments:
//
// [value] string s_dsn
// <description>
// [value] string db_name
// <description>
//--------------------------------------------------------------------
// Returns: (INTEGER)
//--------------------------------------------------------------------
// Author: YX_ZHANG Date: June, 2001
//====================================================================
Int answer,answer1,answer2,answer3,li_flag
String ls_driver,ls_start,ls_location,ls_value,db_path,cur_dir

String ls_apppath = 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\'
String ls_odbc1 = 'HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\'
String ls_odbc2 = 'HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\'
String ls_odbc3 = 'HKEY_USERS\.DEFAULT\Software\ODBC\ODBC.INI\'

answer = RegistryGet(ls_apppath + "dbeng6.exe","Path",RegString!,ls_location)

cur_dir = Space(256)
GetCurrentDirectoryA(256,cur_dir) //取当前目录
/*在注册表中查找文件dbodbc6.dll和dbeng6.exe的位置.若不存在则在当前位置查找.*/
if answer = -1 then
ls_location = cur_dir
ls_driver = ls_location + 'dbodbc6.dll'
ls_start = ls_location + 'dbeng6.exe'
if not (FileExists(ls_driver) AND FileExists(ls_start)) THEN
li_flag = 1
GoTo ErrHandle
else
RegistrySet(ls_apppath + "dbeng6.exe","path",RegString!,ls_location)
RegistrySet(ls_apppath + "dbeng6.exe","",RegString!,ls_start)
end if
else
ls_driver = ls_location + 'dbodbc6.dll'
ls_start = ls_location+'dbeng6.exe'
if not (FileExists(ls_driver) AND FileExists(ls_start)) THEN
li_flag = 1
GoTo ErrHandle
end if
end if
//设置ODBC\ODBCINST.INI\ODBC DRIVERS
answer = RegistryGet(ls_odbc1 + 'ODBC DRIVERS','Adaptive Server Anywhere 6.0',RegString!,ls_value)
if answer = -1 THEN
answer = RegistrySet(ls_odbc1 + 'ODBC DRIVERS','Adaptive Server Anywhere 6.0',RegString!,'Installed')
if answer = -1 then
li_flag = 2
GoTo ErrHandle
end if
answer = RegistrySet(ls_odbc1 + 'Adaptive Server Anywhere 6.0','Driver',RegString!,ls_driver)
if answer = -1 then
li_flag = 2
GoTo ErrHandle
end if
answer = RegistrySet(ls_odbc1 + 'Adaptive Server Anywhere 6.0','Setup',RegString!,ls_driver)
if answer = -1 then
li_flag = 2
GoTo ErrHandle
end if
end if

//设置ODBC DATA SOURCE名称
answer = RegistryGet(ls_odbc2 + 'ODBC Data Sources',s_dsn,RegString!,ls_value)
if answer = -1 THEN
db_path = cur_dir+'\'+db_name+".db"
answer = RegistrySet(ls_odbc2 + 'ODBC Data Sources',s_dsn,RegString!,'Adaptive Server Anywhere 6.0')
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'driver',RegString!,ls_driver)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'start',RegString!,ls_start+' -d -Q -c1024')
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'autostop',RegString!,'yes')
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'DataBaseFile',RegString!,db_path)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'DataBaseName',RegString!,db_name)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'uid',RegString!,"dba")
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc2 + s_dsn,'pwd',RegString!,"sql")
if answer = -1 then GoTo ErrHandle

answer = RegistrySet(ls_odbc3 + s_dsn,"Driver", RegString!,ls_driver)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"uid", RegString!,"dba")
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"pwd", RegString!,"sql")
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"Start", RegString!,ls_start + ' -d -Q -c1024')
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"DatabaseFile", RegString!,db_path)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"DatabaseName", RegString!,db_name)
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + s_dsn,"AutoStop", RegString!, "yes")
if answer = -1 then GoTo ErrHandle
answer = RegistrySet(ls_odbc3 + "ODBC Data Sources",s_dsn, RegString!, "Adaptive Server Anywhere 6.0")
if answer = -1 then GoTo ErrHandle
end if

return 0

ErrHandle:
choose case li_flag
case 1
Messagebox('错误',ls_location + '目录中没有安装dbeng6.exe和dbodbc6.dll文件!',StopSign!)
case 2
Messagebox('错误','应用程序无法设置ODBC DRIVERS,运行不能继续!',StopSign!)
case else
Messagebox('错误','应用程序无法设置ODBC DATA SOURCE,运行不能继续!',StopSign!)
end choose
RETURN -1
回复
leiming 2003-12-12
补充:是自动安装执行,即:不用设置ODBC
回复
cxwsoftware 2003-12-12
bnd!
回复
发动态
发帖子
PowerBuilder
创建于2007-09-28

804

社区成员

PowerBuilder 相关问题讨论
申请成为版主
社区公告
暂无公告