Description:
Hello Sir,
We are using MySql Connector/Net 1.0.7 with ASP.NET (.Net Framework 1.1). We are facing following error continously.
But we are opening and closing connection in a Ideal way i.e. opening a connection before query execution and closing connection after query is executed. Also we have kept "pooling = false".
Following is the connection string which we are using.
"server=test;user id=test;password=test;database=testDB; pooling=false; allow zero datetime=yes"
/////////////////////////////////////////////
Detailed Error.
Reason :: System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
at System.Net.Sockets.Socket.Shutdown(SocketShutdown how)
at MySql.Data.Common.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BufferedStream.ReadByte()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings)
at MySql.Data.MySqlClient.MySqlConnection.Open()
at classbased.DAL.BaseDAL.exeScalarQuery(String strQuery) in c:\inetpub\wwwroot\tosc9\classbased\DAL\BaseDAL.vb:line 118
/////////////////////////////////////////////
Please reply asap..
How to repeat:
Create a simple application which will fetch record from db. Initialize connection on page load.
Then put a loop of 100 or 1000 and inside the loop perform db operation. Open and Close a connection inside loop. Just try following code snippet..
Dim objConn as MySql.MySqlClient.MySqlConnection
Dim objComm as MySql.MySqlClient.MySqlCommand
Publi Sub Page_Load()
objConn.ConnectionString = "server=test;user id=test;password=test;database=testDB; pooling=false; allow zero datetime=yes"
Dim intI as Integer
Dim intCnt as Integer
Dim strSql as String
For intI = 0 to 100
strSql = "SELECT COUNT(*) FROM PRODUCTS"
objComm.CommandText = strSql
objComm.Connection = objConn
objConn.Open()
intCnt = objComm.ExecuteScalar()
objConn.Close()
Next
End Sub