zoukankan      html  css  js  c++  java
  • c# 大批量用户访问数据库报错

    报错信息:There is already an open DataReader associated with this Connection which must be closed first

    缓解的方案:在实例化database的时候利用线程独立实例化,每个线程一个单独的database实例

            [ThreadStatic]
            private static Database _threadInstance = null;
    
            protected Database DB = CreateDatabase();
    
            public static Database CreateDatabase()
            {
                if (_threadInstance == null)
                {
                    _threadInstance = new Database(connectionStr);
                }
                return _threadInstance;
            }

    随笔记录。

  • 相关阅读:
    20151019
    20151013
    20150810
    20150626
    20150625
    20150530
    HTML特殊字符大全
    label标签跳出循环
    IIS 负载均衡
    .NET代码执行效率优化
  • 原文地址:https://www.cnblogs.com/dawenyang/p/9138368.html
Copyright © 2011-2022 走看看