用PB做圖書管理系統,登錄界面需要用戶名密碼
目前知道一種實作方法是寫一個***.ini檔案,存入相應的logid和logpass
然后通過ProfileString函式賦值
但是這樣好像只能有一個用戶名和密碼
如果要實作多用戶的時候
我是這樣做的:
申明變數:
declare abc cursor for
SELECT id,password
FROM users;
//users是一個表,id和password用來存用戶名和密碼
登錄按鈕的clicked事件驅動程式
string ls_id,ls_ps
open abc;
fetch abc into:ls_id,:ls_ps;
IF sle_id.text=ls_id and sle_pass.text=ls_ps THEN
messagebox('系統登入成功','歡迎你的到來,'+ls_id+'!')
close abc;
else
MessageBox('登錄錯誤','用戶名或密碼錯誤,請重新輸入!')
sle_id.text=''
sle_pass.text=''
end if
但是具體執行的時候,只有輸入users表里第一組資料才提示登入成功,其他組都說用戶名或者密碼錯誤...
abc指標要怎樣才能一組一組的驗證id和password呢
uj5u.com熱心網友回復:
select count(*) into :i from user where id = :sle_id.text and password = :sle_pass;if i > 0 then
messagebox('系統登入成功','歡迎你的到來,'+ls_id+'!')
close abc;
else
MessageBox('登錄錯誤','用戶名或密碼錯誤,請重新輸入!')
sle_id.text=''
sle_pass.text=''
end if
uj5u.com熱心網友回復:
用不著定義cursor修改如下:
登錄按鈕的clicked事件驅動程式
string ls_id,ls_ps
int count
ls_id =trim(sle_id.text)
ls_ps =trim(sle_pass.text)
select count(*) into :count
from users where id=:ls_id and password =:ls_ps;
IF count =1 THEN
messagebox('系統登入成功','歡迎你的到來,'+ls_id+'!')
else
MessageBox('登錄錯誤','用戶名或密碼錯誤,請重新輸入!')
sle_id.text=''
sle_pass.text=''
end if
uj5u.com熱心網友回復:
直接寫SQL就行啊,用游標多麻煩啊!而且這寫的有問題,你連條件都沒有!就是查詢全部了
string ls_id,ls_ps
ls_id = trim(sle_id.text)
select password into :ls_ps
from users
where id = :ls_id;
if sqlca.sqlcode = 100 then
MessageBox('登錄錯誤','用戶錯誤,請重新輸入!')
return
end if
if sle_pass.text=ls_ps then
messagebox('系統登入成功','歡迎你的到來,'+ls_id+'!')
close abc;
else
MessageBox('登錄錯誤','密碼錯誤,請重新輸入!')
sle_id.text=''
sle_pass.text=''
end if
uj5u.com熱心網友回復:
都OPEN 了 ABC;執行成功就CLOSE ABC,為什么不成功就不管油標了ABC了?
uj5u.com熱心網友回復:
復制進去以后
select count(*) into :count
這段代碼報錯
uj5u.com熱心網友回復:
string as_emp_id , as_emp_pass
int i
as_emp_id = sle_1.text
as_emp_pass = sle_2.text
if len(as_emp_id) = 0 or len(as_emp_pass) = 0 then
messagebox("錯誤","用戶名或密碼不能為空!",exclamation!,ok!)
return
end if
select 1 into :i
from users
where id = :as_emp_id and
password = :as_emp_pass ;
if sqlca.sqlcode <> 0 then
messagebox("錯誤","用戶名或密碼錯誤,請重新輸入",exclamation!,ok!)
return
end if
//這后面進入系統的代碼
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/107728.html
標籤:數據庫相關
下一篇:電腦不知道怎么回事,速度太慢.CPU1.6,DDR256, 感覺也沒有中毒和木馬.我查殺了.為什么呢?速度感應那么慢.
