祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 5311|回复: 1

[转帖]关于动态注册ODBC数据源.

[复制链接]

[转帖]关于动态注册ODBC数据源.

[复制链接]
jami

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2005-12-21 23:51:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×

1.关于动态注册Access数据源

//***********************************************
//
函数名: gf_setodbc_access
// 功能: 完成access数据源的注册功能

// 输入参数:
// as_database 数据库名

// (即Access数据库文件名字,不含扩展名)
// as_path 数据库文件所在的目录

// 返回值:
// true 表示自动配置成功

// false 表示自动配置失败
// 设计者: Adamswater
// 完成时间: 2005年6月

//***************************************************
boolean lb_rtn
string ls_root,ls_root_dsn,ls_root_Jet,ls_root_Engines
integer li_rtn
string ls_dsnname,ls_dbfullname,ls_driver,temp,ls_version
string ls_syspath
environment env

integer rtn

ls_syspath = Space( 40 )
//
获得操作系统的目录
GetSystemDirectoryA(ls_syspath,60)
ls_driver = ls_syspath + "\odbcjt32.dll"
lb_rtn = true
ls_root = "HKEY_LOCAL_MACHINE\software\odbc\odbc.ini"
//
数据源名字为:文件名字+“_DT”
ls_dsnname = as_database + "_DT"
ls_root_dsn = ls_root + "\" + ls_dsnname
ls_root_Engines = ls_root_dsn + "\" + "Engines"
ls_root_Jet = ls_root_Engines + "\" + "Jet"
ls_dbfullname = as_path + "\" + as_database + ".mdb"
//
注册数据源的名字
li_rtn = registryset(ls_root,ls_dsnname,regstring!,"")
if li_rtn= - 1 then
return false
end if
//
注册数据库名字
li_rtn = registryset(ls_root_dsn,"DBQ",regstring!,ls_dbfullname)
if li_rtn= - 1 then
return false
end if
//
注册数据库驱动程序
li_rtn = registryset(ls_root_dsn,"Driver",regstring!,ls_driver)
if li_rtn= - 1 then
return false
end if

//注册其它项
li_rtn = registryset(ls_root_dsn,"FIL",regstring!,"MS Access;")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"Description",regstring!,"
条形码打印程序")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"UID",regstring!,"")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"DriverId", RegULong!,25)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_dsn,"SafeTransactions", RegULong!,0)
if li_rtn= - 1 then
return false
end if
//注册"Engines"项

li_rtn = registryset(ls_root_dsn,"Engines",regstring!,"")
if li_rtn= - 1 then
return false
end if
//
注册"Jet"项
li_rtn = registryset(ls_root_Engines,"Jet",regstring!,"")
if li_rtn= - 1 then
return false
end if
//
注册"Jet"项的各个子项
li_rtn = registryset(ls_root_Jet,"ImplicitCommitSync",regstring!,"")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"UserCommitSync",regstring!,"Yes")
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"MaxBufferSize", RegULong!,2048)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"PageTimeout", RegULong!,5)
if li_rtn= - 1 then
return false
end if
li_rtn = registryset(ls_root_Jet,"Threads", RegULong!,3)
if li_rtn= - 1 then
return false
end if
return lb_rtn

2.关于动态注册DBF数据源

//************************************************************//
//
函数名: autosetodbc //
// 功能: 主要是根据传入的库文件名,自动完成ODBC的配置
//
// 一文件名在ODBC中注册数据源
//
// 输入
: //
// ls_file 文件名称(主要是库文件
) //
// ls_path 文件所在的目录
//
// as_drivedir 驱动程序路径
//
// 返回值
: //
// 1 表示自动配置成功
//
// 0 表示自动配置失败
//
// 设计者
: Adamswater //
// 完成时间: 2003年10月
//
// //
//************************************************************//
integer li_return //返回值

string ls_filename //库文件名
string ls_fileend //文件的扩展名
string ls_filedir //文件所在的目录
string ls_driver //驱动程序
integer li_rtn
blob lb_value
string ls_root
string ls_root_table

li_return = 1
ls_driver = as_drivedir + +"\vfpodbc.dll"
ls_fileend = right(ls_file,3) //
获得文件的扩展名
ls_filename = left(ls_file,pos(ls_file,'.',1) - 1) //获得文件名
ls_filedir = ls_path//left(ls_path,lastpos(ls_path,'\') - 1)
ls_root = "HKEY_LOCAL_MACHINE\software\odbc\odbc.ini"
ls_root_table = ls_root + "\" + ls_filename
if ls_fileend="dbf" then
//
先判断是否已经注册过
//当选择的是DBF文件时
li_rtn = registryset(ls_root,ls_filename,regstring!,"")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"BackgroundFetch",regstring!,"Yes")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Collate",regstring!,"Machine")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Deleted",regstring!,"Yes")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Collate",regstring!,"Machine")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Description",regstring!,"")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Driver",regstring!,ls_driver)
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Exclusive",regstring!,"No")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"Null",regstring!,"Yes")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"SetNoCountOn",regstring!,"No")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"SourceDB",regstring!,ls_filedir)
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"SourceType",regstring!,"DBF")
if li_rtn= - 1 then
return 0
end if
else
end if
return li_return

3.关于动态注册SQL Server数据源

//***********************************************
//
函数名: 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

4.关于动态注册ASA数据库ODBC数据源

//************************************************************//
// 函数名: //
// 功能: 主要是根据传入的库文件名,自动完成ODBC的配置 //
// 一文件名在ODBC中注册数据源 //
// 输入: //
// ls_filename 文件名称(主要是库文件) //
// ls_dir 文件所在的目录 //
// 返回值: //
// 1 表示自动配置成功 //
// 0 表示自动配置失败 //
// 设计者: Adamswater //
// 完成时间: 2003年10月 //
//************************************************************//
integer li_return //返回值
string ls_filename
integer li_rtn
string ls_root
string ls_root_table

ls_filename = as_filename + ".db"//获得数据库文件名字


ls_root = "HKEY_LOCAL_MACHINE\software\odbc\odbc.ini"
ls_root_table = ls_root + "\" + as_filename
li_return = 1
li_rtn = registryset(ls_root,as_filename,regstring!,"")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"AutoStop",regstring!,"Yes")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"Compress",regstring!,"NO")
if li_rtn= - 1 then
return 0
end if
li_rtn = registryset(ls_root_table,"DatabaseFile",regstring!,as_dir + "\"+ls_filename)
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"DatabaseName",regstring!,as_filename)
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"Debug",regstring!,"NO")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"DisableMultiRowFetch",regstring!,"NO")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"Driver",regstring!,as_dir + "\"+"dbodbc8.dll")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"Start",regstring!,as_dir + "\"+"dbeng8.exe -d -c8m")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"EngineName",regstring!,"ndjwglxt")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"Integrated",regstring!,"No")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"PWD",regstring!,"jwglxt")
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"UID",regstring!,"jwglxt")
if li_rtn= - 1 then
li_return = 0
end if
return li_return

IsUninst "/UNINST=D:\111\UnInst.log" "/APPNAME=学生管理系统"

C:\WINNT\GPInstall.exe "/UNINST=D:\111\UnInst.log" "/APPNAME=学生管理系统"

共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
awang

主题

0

回帖

24

积分

版主

积分
24
贡献
在线时间
小时
2005-12-26 23:57:08 | 显示全部楼层

哈哈

这是我的

支持!

[em02]
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-4-29 08:55 , Processed in 0.086668 second(s), 10 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表