//************************************************************//
// 函数名: //
// 功能: 主要是根据传入的库文件名,自动完成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_mm
ls_filename = as_filename + ".db"//获得数据库文件名字
ls_root = "HKEY_LOCAL_MACHINE/software/odbc/odbc.ini"
ls_root_table = ls_root + "/" + as_filename
//先判断是否已经注册过
//若还没注册过
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
//'"C:/Program Files/Sybase/SQL Anywhere 8/win32/dbeng8.exe" -d -c8m'
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!,"database")
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
ls_mm = left(MDString('ywdba',len('ywdba')),20)
li_rtn = registryset(ls_root_table,"PWD",regstring!,ls_mm)
if li_rtn= - 1 then
li_return = 0
end if
li_rtn = registryset(ls_root_table,"UID",regstring!,"ywdba")
if li_rtn= - 1 then
li_return = 0
end if
return li_return