PB登陆界面

mangmangdashi 2009-05-16 10:48:17
就是最简单的界面。
可是不知为什么运行起来似乎没跟数据库连接一样。不论怎么样,都说 密码错误,刻数据库密码就是那个啊,而且我乱输入账号,也竟然不说无此用户。且不提示次数限制到三次。究竟怎么回事
string ls_uname,ls_pwd1,ls_pwd2,ls_sno,ls_s1
ls_uname=sle_uname.text
ls_pwd1=sle_pwd.text
select USER_NAME
into :ls_sno
from USER_TABLE
where USER_NAME=:ls_uname;
if sle_uname.text="" or sle_pwd.text="" then
messagebox("提示","用户名或密码不能为空,请输入用户名或密码!")
sle_uname.text=""
sle_pwd.text=""
return
end if
If SQLCA.SQLCode = 100 Then
MessageBox( "注意 ", "无此用户! ",Exclamation!)
sle_uname.text = " "

sle_uname.SetFocus()
Return
end if
select USER_PWD
into :ls_pwd2
from USER_TABLE
where USER_NAME=:ls_uname ;
if ls_pwd1 = ls_pwd2 then
open(汽车库位管理)
close(w_denglujiemian)
else
messagebox("错误","用户名或密码错误,请重新输入!")
sle_pwd.text=""
return
end if


这个是不是只要数据库连上了就行了?还有其他的什么要做吗?
If SQLCA.SQLCode = 100 Then
MessageBox( "注意 ", "无此用户! ",Exclamation!)
sle_uname.text = " "

sle_uname.SetFocus()
Return
end if
这段话似乎用了没什么用处。还是一样。。。
...全文
1029 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
herolion2010 2010-01-07
  • 打赏
  • 举报
回复
确保你的数据库连接好了.(PB9连接例子
SQLCA.DBMS = "MSS Microsoft SQL Server"
SQLCA.Database = "test"
SQLCA.LogPass = ''
SQLCA.ServerName = "china"
SQLCA.LogId = ""
SQLCA.AutoCommit = False
SQLCA.DBParm = ""
connect using sqlca;

open(登录窗口)

//写在应用开始)



string ls_uname,ls_pwd1,ls_temp ,ls_pwd
long li_i

if sle_uname.text ='' or isnull(sle_uname.text ) then
messagebox('警告','用户名不能为空!')
sle_uname.setfocus()
return
end if
if sle_pwd.text ='' or isnull(sle_pwd.text ) then
messagebox('警告','密码不能为空!')
sle_pwd.setfocus()
return
end if
ls_uname=sle_uname.text
ls_pwd=sle_pwd.text

select user_name ,user_pwd into :ls_temp,:ls_pwd1 from USER_TABLE where USER_NAME=:ls_uname;
commit;

i++ //i 定义为局部变量 long i=0 //登录窗口的 instance var....里写
if i=3 then
messagebox('警告','你已3次输入错误登录信息!,系统挂起')
halt;
end if
if isnull(ls_temp) or ls_temp='' then
messagebox('警告','用户不存在')
sle_uname.setfocus()
sle_uname.text=''
return
elseif ls_pwd1<>ls_pwd then
messagebox('警告','用户密码不正确')
sle_pwd.setfocus()
sle_pwd.text=''
return
else
open(main)//打开你的主窗口
end if
mangmangdashi 2009-05-20
  • 打赏
  • 举报
回复
多谢了。
可是不知为何结不了贴
builderwfy 2009-05-17
  • 打赏
  • 举报
回复
数据都没有连接上
newease 2009-05-17
  • 打赏
  • 举报
回复
http://blog.csdn.net/newease/archive/2009/05/03/4144639.aspx
newease 2009-05-17
  • 打赏
  • 举报
回复
那我之前的用OLE MS OLE DB 连接后不算连接上? 用ODBC OLEDB 直接等等都可以,只要确定能已经连接就行
在你的连接语句后
加一
Messagebox('error',sqlca.sqlerrtext)

看看有没有错误提示
mangmangdashi 2009-05-17
  • 打赏
  • 举报
回复
那我之前的用OLE MS OLE DB 连接后不算连接上?
还要重新在写这段程序?那写哪里?也是这段程序里面?
newease 2009-05-17
  • 打赏
  • 举报
回复
就是下面一段简单的用ODBC连接的代码:

//profile mydb
sqlca.dbms="ODBC"
sqlca.autocommit = false
sqlca.dbparm ="connecttring='dsn=mydb;uid=dba;pwd=sql'"

//connect datebase 连接数据库
connect;

if sqlca.sqlcode<>0 then
Messagebox('error','connect datebase failed')
halt
else
open(w_login)
end if

newease 2009-05-17
  • 打赏
  • 举报
回复
数据库没有连接
mangmangdashi 2009-05-17
  • 打赏
  • 举报
回复
运行后显示:transaction not connected。
怎么回事?
newease 2009-05-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Awang_126 的回复:]
select USER_NAME
into :ls_sno
from USER_TABLE
where USER_NAME=:ls_uname;

这个后面增加语句:
messagebox("",sqlca.sqlerrtext)
看看有什么错误
[/Quote]

如果按照1楼的办法,没有显示错误信息.
你看看在你程序文件夹内是否含有PB发布的动态库和sql动态库,如果有你先删除,然后再试试看
rightyeah 2009-05-17
  • 打赏
  • 举报
回复
路过
Awang_126 2009-05-17
  • 打赏
  • 举报
回复
select USER_NAME
into :ls_sno
from USER_TABLE
where USER_NAME=:ls_uname;

这个后面增加语句:
messagebox("",sqlca.sqlerrtext)
看看有什么错误
newease 2009-05-17
  • 打赏
  • 举报
回复
一般数据库连接都写在application中

连接成功后,如果不断开数据连接,其它窗口中就可以一直使用
mangmangdashi 2009-05-17
  • 打赏
  • 举报
回复
是不是连接好后一定要把那个语言复制进去?
那是不是只要用在一个里面就行了,
以后的就不用写了?

604

社区成员

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

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