请大家帮我看看这段程序,在工程的open事件中为什么始终不可以呢?

bobo101 2003-10-21 11:45:27
string fla
string s_ser
string s_db
string s_id
string s_ps
fla=upper(trim(profilestring("cxc.ini","DATABASE","CON","")))
s_db=profilestring("cxc.ini","DATABASE","DATABASE","")
s_id=profilestring("cxc.ini","DATABASE","USERID","")
s_ser=profilestring("cxc.ini","DATABASE","SERVERNAME","")
str=trim(profilestring("cxc.ini","DATABASE","LOGPASS",""))
s_ps=f_decrypt(str)
IF fla="DIRECT" THEN
SQLCA.DBMS = "MSS Microsoft SQL Server
SQLCA.Database = s_db
SQLCA.UserID = ""
SQLCA.DBPass = ""
SQLCA.LogID = s_id
SQLCA.LogPass = s_ps
SQLCA.ServerName = s_ser
SQLCA.AUTOCommit=false
Connect using SQLCA;
IF SQLCA.SQLCode<>0 THEN
close(w_dl)
open(w_connect)
RETURN
END IF
open(w_dl)

ELSE
IF fla="ODBC" then
SQLCA.DBMS = "ODBC
SQLCA.DBParm = "ConnectString='driver=SQL Server;server="+s_ser+";database="+s_db+";UID="+s_id+";PWD="+s_ps+"'"
SQLCA.AUTOCommit=false
Connect using SQLCA;
IF SQLCA.SQLCode<>0 THEN
close(w_dl)
open(w_connect)
RETURN
END IF
open(w_dl)

else
open(w_connect)
end if
end if
其中:f_decrypt()是自编的解密函数,与加密函数f_endrypt()对应,函数加密解密完全正常,没有出现解密错误!
...全文
34 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongyou2003 2003-10-21
  • 打赏
  • 举报
回复
string fla
string s_ser
string s_db
string s_id
string s_ps
fla=upper(trim(profilestring("cxc.ini","DATABASE","CON","")))
s_db=profilestring("cxc.ini","DATABASE","DATABASE","")
s_id=profilestring("cxc.ini","DATABASE","USERID","")
s_ser=profilestring("cxc.ini","DATABASE","SERVERNAME","")
str=trim(profilestring("cxc.ini","DATABASE","LOGPASS",""))
s_ps=f_decrypt(str)
IF fla="DIRECT" THEN
SQLCA.DBMS = "MSS Microsoft SQL Server
SQLCA.Database = s_db
SQLCA.UserID = ""
SQLCA.DBPass = ""
SQLCA.LogID = s_id
SQLCA.LogPass = s_ps
SQLCA.ServerName = s_ser
SQLCA.AUTOCommit=false
Connect using SQLCA;
IF SQLCA.SQLCode<>0 THEN
open(w_connect)
close(w_dl)
else
open(w_dl)
END IF
ELSE
IF fla="ODBC" then
SQLCA.DBMS = "ODBC
SQLCA.DBParm = "ConnectString='driver=SQL Server;server="+s_ser+";database="+s_db+";UID="+s_id+";PWD="+s_ps+"'"
SQLCA.AUTOCommit=false
Connect using SQLCA;
IF SQLCA.SQLCode<>0 THEN
open(w_connect)
close(w_dl)
else
open(w_dl)
END IF
else
open(w_connect)

end if
end if
你试一下呢



bobo101 2003-10-21
  • 打赏
  • 举报
回复
判断sqlcode = -1也是执行if ..then ..end if 之间的语句,他不给跳出来!
workhand 2003-10-21
  • 打赏
  • 举报
回复
应该可以吧,提示什么信息?
判断sqlcode = -1 呢
bobo101 2003-10-21
  • 打赏
  • 举报
回复
上面的程序,只要是改过来那一点错误的话,完全可以正常运行
bobo101 2003-10-21
  • 打赏
  • 举报
回复
谢谢各位的热心,我的问题解决了,是我上面的输入有问题在:
s_id=profilestring("cxc.ini","DATABASE","USERID","")
应该是:s_id=profilestring("cxc.ini","DATABASE","LOGID","")
bobo101 2003-10-21
  • 打赏
  • 举报
回复
to cmaboy(cmaboy) 还是 不可以,我都试过了,如果上面直接输入数据库名、用户名、密码、服务器,就是SQLCA.UserID = "" SQLCA.DBPass = ""的话也可以连接上,就是从ini文件中读出的不可以!
cmaboy 2003-10-21
  • 打赏
  • 举报
回复
SQLCA.UserID = "sa"
bobo101 2003-10-21
  • 打赏
  • 举报
回复
to hongyou2003(白玫瑰),你更改的是,close(w_dl)与open(w_connect)的次序,我把close(w_dl)去掉了也不行!也是不给执行if ..end if外面的语句,也就是说不能够连接上数据库!
bobo101 2003-10-21
  • 打赏
  • 举报
回复
哦,不好意思,我复制上的就缺少引号,不过我的程序时没有缺少的
bobo101 2003-10-21
  • 打赏
  • 举报
回复
to hongyou2003(白玫瑰),你更改的去掉了"MSS Microsoft SQL Server后的"和"ODBC后的"
那样的话系统报错,不能编译!

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧