Conn.RollBackTrans使用

'--------------ATM密码验证-------------------
    atm_pwd=trim(request.form("atm_pwd"))
   
   if len(atm_pwd)<>6 then
    call openw("ATM服务密码长度为6位","")
    response.end
   end if
      
   UID=get_dvid(session("username"),"username")
   call check_userinfo(UID,2,2,1,atm_pwd,1)
   '--------------------------------------------

    sql="select money from [user] where username='" & session("username") & "'"
   MyMoney=cdbl(conn.execute(sql)(0))
   
   if not isnumeric(Request("CsMoney")) then
    call openw("注入酷币必须为数字!","")
   end if
   if request("csmoney") <1 then
    call openW("酷币不能为负数或零!","")
   end if
   
   if  request("csmoney") >10000 then
    call openw("每次注入的酷币不得大于10000","")
   end if

   if cdbl(Request("CsMoney"))>MyMoney then
    call openw("您注入的酷币大于你拥有的酷币!","")
   end if
   
   if lenB(Request("sDemo"))>200 then
    call openw("您留言不能超过100个汉字!","")
   end if

            '############检测酷币来源#############
            '   call  checkmoney(Request("CsMoney"))
   conn.errors.clear
   Conn.BeginTrans
   
   'moduleid 1 为 社员加入酷币到社团中  2 为 社团将酷币 分配 到 社员中
   sql="Insert MemberAddMoney(TeamID,MemberID,CSMoney,AddDate,Message,moduleid) values('" & TeamID & "','" & session("username") & "'," & Request("CsMoney") & ",'" & now & "','" & Request("sDemo") & "',1)"
   conn.execute sql

   sql="update [user] set money=" & MyMoney-Request("CsMoney") & " where username='" & session("username") & "'"
   conn.execute sql
   
   sql="update TeamData set CSMoney=CSMoney+ " & Request("CsMoney") & " where TeamID='" & TeamID & "'"
   conn.execute sql
   
   if conn.errors.count>0 then
    conn.errors.clear
    conn.rollbacktrans
    call openw("酷币注入失败,请联系迪酷客服","")
   else
    conn.commitTrans
    call openw("酷币注入成功","teamcsmoneyadd.asp")
   end if 

使用连接池可以提高LDAP操作的性能。LDAP连接池是一组LDAP连接,它们被预先创建并保持在内存中,以便在需要时可以重用。这可以减少连接创建和销毁的开销,并提高LDAP操作的性能。 在使用LDAP连接池时,可以使用`ConnectionPool`类来创建和管理连接池。以下是使用连接池来绑定LDAP服务器的示例代码: ```python from ldap3 import Server, Connection, ConnectionPool, SIMPLE, SYNC, ALL # 创建LDAP服务器 server = Server('ldap://localhost:389') # 创建连接池 pool = ConnectionPool(server, user='cn=admin,dc=example,dc=com', password='secret', authentication=SIMPLE, client_strategy=SYNC, pool_size=10, pool_lifetime=60, pool_keepalive=True, exhaust=True) # 从连接池获取连接 with pool.get_connection() as conn: # 绑定LDAP服务器 conn.bind() # 执行LDAP操作 conn.search(search_base='dc=example,dc=com', search_filter='(objectClass=person)', search_scope=ALL, attributes=['cn', 'sn']) # 关闭连接 conn.unbind() ``` 在上面的代码中,我们首先创建了一个LDAP服务器对象`server`,然后使用`ConnectionPool`类创建了一个连接池`pool`,其中包含10个连接。我们使用`pool.get_connection()`方法从连接池中获取一个连接`conn`,然后使用`conn.bind()`方法绑定LDAP服务器。接下来,我们执行一些LDAP操作,最后使用`conn.unbind()`方法关闭连接。使用`with`语句可以确保在使用完连接后自动将其返回到连接池中。 在创建连接池时,可以设置各种选项,例如连接池的大小、生命周期、保持活动状态等。这些选项可以根据实际情况进行调整,以获得最佳的性能和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值