When connecting to a database " general network error " Alternative explanation

Source: Internet
Author: User
Tags date documentation execution microsoft sql server connect ole
Error | Connection Database | network


Occurs when connecting to a database



"General network Error"



The alternative explanation


Revision History:
Version

Date

Creator

Description

1.0.0.1

2003-11-15

Zheng

Draft
Implementation Scope:
This document describes a "general network error" that occurs when a database is not easy to think about, and the source of the error report is ADODB, the error number is "2147467259, or 0x80004005."



Before continuing, let's assume you are familiar with the following knowledge:

n Microsoft SQL Server 2000

N Microsoft ADO
Keywords:
SQL Server, ADO, DBMSSOCN, 0x80004005


Phenomenon
One day, suddenly there was such a question in front of him:

When a user browses to a workflow system, it suddenly runs out of the error:

Microsoft VBScript Compiler error ' 800A03F6 '



Missing ' End '



/iishelp/common/500-100.asp, Line 242



Microsoft OLE DB Provider for SQL Server error ' 80004005 '



[DBMSSOCN] General network error. Please check your network documentation.



/xxx/yyyframe.asp, line 23



After troubleshooting, the real reason is that an exception occurs when invoking ADO to connect to SQL Server 2000, and the error description is "[DBMSSOCN] General network error." Please check your network documentation. "The Microsoft OLE DB Provider for SQL Server error ' 80004005 ' doesn't really mean much.



Why the "[DBMSSOCN] General network error is suddenly appearing." "Then?"

The server page calls the encapsulated COM + STA component, which is actually the component that connects SQL Server 2000.

It later provides a more important message, and when these things happen, note that the COM + application process consumes 200MB of memory.
A preliminary conjecture
I've had this mistake in other places before.

However, that is because the network card or network cable flash break ("Network is Down"), resulting in the failure to connect the database, service and constantly try to connect. Do not know under what circumstances the service continues to report:

Error Environment Description: COM exception occurred while running SQL command to read records from the database;

Error description: [DBMSSOCN] General network error. Please check your network documentation.

Error Number:-2147467259

"[DBMSSOCN]" refers to the current communication with the database using the TCP/IP protocol.



However, the network quality of this environment is no problem.
Simulation test
Experts say it is possible because the connection between the same server and SQL Server is not close, causing the connection to reach the maximum number allowed and is closed all.

So we experimented and looked at how many connections a server was allowed to establish with SQL Server.
More information
The Initadocmd (_command** ppicmd) method in the original project is reused in the test program.

This method uses the Ado.command::p Ut_activeconnection method to establish a database connection:

Varconn = _bstr_t ("Provider=SQLOLEDB.1; ...");

hr = T_picmd->put_activeconnection (varconn);



In a Windows XP environment, the loop calls this function 1980 times, and the program pauses for a few seconds. After that, you get the 0x80004005 error return value. This value is returned by the Put_activeconnection method and is not an exception. So the ADO exception description is not visible.

When we stall through the test program, we immediately request a database connection with a VBS script. As a result, the VBS script stalls together, and after a few seconds, throws an exception, which is described as:

"[Dbnetlib][connectionopen (PreLoginHandshake ()).] General network error. Please check your network documentation. "



After the 1981, 1982 、... The second put_activeconnectio call will be the same error return value.



In SQL Server Profiler, there are only audit login events until you see 1980 calls. Unless you close the test program, you will be able to swish all the audit logout events out.



Sometimes, when a 1981th request to establish a connection is considered by SQL Server 2000 to be outside the allowable range, SQL Server 2000 proactively interrupts all 1000 connections at the same time. So, in SQL Server Profiler, you can also see all the audit logout events coming out.



If the test program maintains these database connections, the memory continues to grow, as follows:



On WinXP (the number of connections allowed on Win2000 is small),



Situation 1:

Simple repeated execution of Ado.command::p ut_activeconnection, only "Audit Login" event, there is no logout event. When this request reaches up to 1980, a "General network error" occurs.



Situation 2:

If it is repeated execution

Ado.command::p ut_activeconnection method, and then execute the query, return the recordset, this cycle up to 483, there will be "general network error."



In the actual test, the 1th situation, the first demo used 6MB memory, the last accumulation of memory is: 104MB.

In the 2nd case, the first demo used 6MB memory, the last accumulated memory is: 39.5MB.















You can look through the following SQL statements to see where the current connections to SQL Server are from and how many:

SELECT Dbid,db_name (dbid) as Dbname,hostname,status,last_batch

From sysprocesses

WHERE db_name (dbid) = '%yourdatabasename% ' and (Last_batch > ' yy-mm-dd ')

ORDER BY Last_batch DESC


Summarize:
While this is a rare occurrence, if you exclude the quality of the network, you may be able to note whether the current server and SQL Server connection number are in an upswing.

When the connection is increasing, be careful that the server connected to the database has a certain limit, and reached the maximum, the other program requests the connection again, you may get a "General network error" warning, and error number 80004005 does not indicate exactly what happened, SQL Server and ADO do not tell you that the number of connections has reached its maximum value.


Disclaimers:
The information contained in this document represents the current view of the issues discussed at the date of release, Zhengyun. This document should not be construed as a commitment by the Zhengyun party, Zhengyun does not guarantee the accuracy of the information given after the date of release.

This document is for informational purposes only.

The user must comply with all applicable copyright laws. Without limiting the rights set forth in copyright law, no part of this article shall be reproduced, transmitted in any form or by any means (electronic, mechanical, photocopying, recording, etc.), for any purpose, in any manner or by a zhengyun and csdn.net, unless expressly permitted in writing by the author, It may not be stored or introduced into a retrieval system.



Thank Tian&wu

Writen by ZHENGYUN_USTC (at) hotmail.com






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.