熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PB編程 >> 正文

PB應用的數據庫聯接的安全防范[2]

2013-11-23 17:27:27  來源: PB編程 

  控件名稱 控件屬性

  sle_server SingleLineEdit

  sle_login SingleLineEdit

  sle_oldkl SingleLineEdit

  sle_pass SingleLineEdit

  sle_repass SingleLineEdit

  cb_ commandbutton

  cb_ commandbutton

  cb_命令按鈕的clicked事件如下

  string ls_inifilels_passls_logidls_repassls_old

  string ls_kls_userls_sql

  ls_inifile =rsglini

  transaction pub_tr

  pub_tr = create transaction

  pub_trDBMS = ProfileString (ls_inifile database dbms

  pub_trLogPass = pub

  pub_trServerName = sle_servertext

  pub_trLogId = pub

  pub_trAutoCommit = False

  pub_trDBParm =

  connect using pub_tr;

  ls_old = sle_oldkltext

  ls_user = lower(trim(sle_logidtext))

  //得到數據庫聯接原用戶口令

  select passshadow into :ls_k from tbl_pub_passshadow using pub_tr;

  if ls_old <> f_password(ls_k) then

  messagebox(提示原口令不對!

  return

  end if

  //檢查核對口令

  ls_pass = sle_passtext

  ls_repass = sle_repasstext

  if ls_repass <> ls_pass then

  messagebox(核對口令不對請重新輸入!

  return

  end if

  SetProfileString(ls_inifile Database Servernamesle_servertext)

  SetProfileString(ls_inifile Database Logidls_user)

  //修改數據庫用戶的聯接口令

  ls_sql = alter user +ls_user+ identified by +ls_pass

  Execute Immediate :ls_sql using sqlca;

  ls_pass = f_password(ls_pass

  UPDATE TBL_PUB_PASSSHADOW SET PASSSHADOW =:ls_pass using pub_tr ;

  commit using pub_tr;

  commit using sqlca;

  disconnect using pub_tr;

  close(parent)

  cb_命令按鈕的clicked事件如下close(parent)

  到此萬事OK

  所有代碼已在Win環境下用PowerBuilder 測試通過

      編輯推薦

       ASP NET開發培訓視頻教程

       Microsoft NET框架程序設計視頻教程

[]  []  


From:http://tw.wingwit.com/Article/program/PB/201311/24611.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.