0

我收到了这个错误:

-InnerException {"Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=86; handshake=2368; [Login] initialization=0; authentication=0; [Post-Login] complete=12018; "}  System.Exception {System.Data.SqlClient.SqlException}

由此:

       DataSourceContext Context = new DataSourceContext();
        var Booklist = Context.Booklists.ToList();
        Context.Dispose();
        Parallel.ForEach(Booklist, currentBook =>
        {
            switch (currentBook.FKcatalogNum)
            {
                case 0:
                    {
                       ...

                        finally
                        {

                                currentBook.BookDetails = Models.DBBookSourceInitializer.GetBookReaderNet(currentBook.Link);
                                try
                                {
                                    context.Booklists.AddOrUpdate(currentBook);
                                    context.SaveChanges();
                                }
                                catch (Exception e)
                                {
                                    ...

                                    context.Booklists.AddOrUpdate(currentBook);
                                    context.SaveChanges();

                            }
                            context.Dispose();
                        }
                        break;

我试图从数据库中获取所有书名,并添加有关其摘要、章节、页数等的详细信息。但我不断收到连接错误。有成千上万本书,在处理了一定数量的东西后,它给了我这个错误。从最后处理的一本书的主键来看,是1180,也就是说1180本很好,然后突然就这样了。有人可以告诉我我做错了什么,或者我应该改变什么。谢谢您的帮助。

4

0 回答 0