Hello dears,
I m facing below mentioned Error in my application.
where as all my database connections are closed.

my code is as under:
i have made a function that is being used with each type of query in my application.

Public Function exeQuery(ByVal query As String) As String
        Dim msg As String
        Try
            connect()
            fComm = New SqlCommand(query, fConn)
            fComm.ExecuteNonQuery()
            fConn.Close()
            fConn.Dispose()
            Return "1"
        Catch ex As Exception
            fConn.Close()
            msg = ex.Message.ToString()
            Return msg
        Finally 
            fConn.Close()
        End Try
    End Function

'Execute Insert, Update and Delete Queries
but when 3 or 4 person use this at the same time it gives the error.
Please suggest me most convenient way at earliest.

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.

Best Regards,

Naveed

Cant comment without viewing the Connect() function.

Check whether the function is returning where u have given the Return 1 statement without calling the finally block.
You can check whether any Datareaders remains unclosed.

In your connection string to the database add Pooling=False;

I caution you, however, there is something "seriously concerning" if you are exceeding 100 connections to your db at the same time. make sure you are closing out your connections! do you have background threads using the db????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.