| General network error. Check your network documentation |
|
You are getting this error while your code is retrieving data from the database. General network error. Check your network documentation This error generally occurs as the result of the program request large amount of database from the database. The default timeout for the connection is 30 seconds. Once the connection elapse over these 30 seconds you will get a timeout expired error. To fix this issue normally you can do one of two things. 1. You can set the timeout setting in the config file. Although this does not always work. <add key="DBConnection" value="server=LocalHost;uid=sa;pwd=;database=DataBaseName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/> 2. Setting the CommandTimeout in the Command object. The CommandTimeout excepts an integer input and this value is represented in seconds. So if you want to set the timeout for 10 minutes you would set it like this: cmd.CommandTimeout = 600 EXAMPLES: Public Function GetShutReport(ByVal psSearchText As String, _ ByVal pdtBeforeDate As DateTime, _ ByVal pdtAfterDate As DateTime) As SqlDataReader Dim db As Database = DatabaseFactory.CreateDatabase() Dim cmd As DBCommandWrapper = db.GetStoredProcCommandWrapper("usp_ReportShuts")
cmd.CommandTimeout = 600
cmd.AddInParameter("@searchtext", DbType.String, GetDefaultValue(psSearchText)) cmd.AddInParameter("@beforedate", DbType.Date, GetDefaultValue(pdtBeforeDate)) cmd.AddInParameter("@afterdate", DbType.Date, GetDefaultValue(pdtAfterDate))
Return db.ExecuteReader(cmd) End Function
|