回 帖 发 新 帖 刷新版面

主题:[讨论]在登录窗口的clicked()中设置用户和密码,为何这样不行?

我的代码如下:



char pwd

INSERT INTO operator
         ( operator_id,
              operator_name,
              password,
              permission)  
        VALUES ( '1',   
              'tian',   
              'tian',  
                 'limit')  ;     
SELECT password
INTO   :pwd 
FROM operator
WHERE operator_id=:sle_operator_id.text and operator_name=:sle_operator_name.text;
//判断用户输入的用户名是否正确
if  sle_operator_id.text="" or sle_operator_name.text="" or sle_password.text=""then
    messagebox("错误!","用户id或用户名或密码不能为空!")
else
if sle_password.text=pwd  then
    open(w_main)
    close(w_login)
else
    messagebox("错误!","用户名或密码错误,请重新输入!")
end if
end if

没有提示错误,但是在运行时输入用户名和密码时提示"用户名或密码错误"

这是怎么一回事?我应该怎样修改才正确??
请热心的大虾们帮帮忙,谢谢!

回复列表 (共3个回复)

沙发

你在插入的语句后边没有提交
char pwd

INSERT INTO operator
         ( operator_id,
              operator_name,
              password,
              permission)  
        VALUES ( '1',   
              'tian',   
              'tian',  
                 'limit')  ;     
SELECT password
INTO   :pwd 
FROM operator
WHERE operator_id=:sle_operator_id.text and operator_name=:sle_operator_name.text;
commit;
//判断用户输入的用户名是否正确
if  sle_operator_id.text="" or sle_operator_name.text="" or sle_password.text=""then
    messagebox("错误!","用户id或用户名或密码不能为空!")
else
if sle_password.text=pwd  then
    open(w_main)
    close(w_login)
else
    messagebox("错误!","用户名或密码错误,请重新输入!")
end if
end if

板凳


还是不行,提示错误......
我在表中插入了用户名和密码,另用一段代码解决了....
不过还是谢谢帮忙

3 楼

你应该判断你的插入语句还有select语句是否执行成功然后分别选择提交或者回滚,另外还可以用消息函数验证你插入的数据是否正确。剩下基本没有什么问题了

我来回复

您尚未登录,请登录后再回复。点此登录或注册