如果判断是否连接到数据库?

fly_rain 2002-11-29 05:47:33
我要连接的是oracle数据库,通过在做好的文本框输入用户,密码,服务器名后来进行连接,在程序中应该如何来判断是否已经连接到数据库,我用sqlca.sqlcode<>0来判断,老是不对,请教教我,谢谢!
...全文
33 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pbtech 2002-11-30
  • 打赏
  • 举报
回复
用connect using sqlca ,然后sqlca.sqlcode <>0 不就行了吗~~~
fly_rain 2002-11-30
  • 打赏
  • 举报
回复
THANKS
one_bird 2002-11-30
  • 打赏
  • 举报
回复
Try SQLCA.DBHandle() .

if SQLCA.DBHandle() = 0 then
NOT CONNECT
else
CONNECT
end if
banalman 2002-11-30
  • 打赏
  • 举报
回复
if Sqlca.dbHandle() >0 then
MessageBox("","Connect!")
else
MessageBox("","Connect error!")
end if
jdsnhan 2002-11-29
  • 打赏
  • 举报
回复
奇怪,sqlca.sqlcode<>0不行吗?继续关注
ideage 2002-11-29
  • 打赏
  • 举报
回复
Description

Reports the handle for your DBMS.

Controls

Transaction objects

Syntax

transactionobject.DBHandle ( )

Argument Description
transactionobject The current transaction object
Return value

UnsignedLong. Returns the handle for your DBMS. Transactionobject must exist, and the database must be connected. If transactionobject is NULL, DBHandle returns NULL. If transactionobject does not exist, an execution error occurs. If there is not enough memory to connect to your DBMS, DBHandle returns a negative number.

Usage

DBHandle returns a valid handle only if you are connected to the database. It is not able to determine if the database connection does not exist or has been lost.
PowerBuilder uses the database handle internally to communicate with the database. If your database supports an API with functions that PowerBuilder doesn't support, you can use DBHandle to provide the handle as an argument to one of these external functions.
gwolfupb 2002-11-29
  • 打赏
  • 举报
回复
应该可以的啊,你的代码怎么写的啊,不会没有加connect;语句吧:)

1,079

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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