Timeout expired. The timeout period elapsed prior to completion of the operation or the server..., elapsedserver ..
Problem:
Recently, the program always throws the following exception:
An exception of type 'System. Data. SqlClient. SqlException 'occurred and was caught.
----------------------------------------------------------------------------------
Type: System. Data. SqlClient. SqlException, System. Data, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089
Message: Timeoutexpired. The timeout period elapsedprior to completion of the operation or the server is not responding.
Source:. Net SqlClient Data Provider ......
...... Database. ExecuteReader (DbCommandcommand )......
Data Reading times out.
Then I checked the corresponding tables in the DataBase and found that the table structure is simple, but the data volume is large, with hundreds of thousands or millions of entries. Check whether you have created Indexes/Keys.
Solution:
Based on the table structureUnique key under Indexes/Keys, Similar to the following:
ALTER TABLE [dbo].[ZData] add CONSTRAINT [IX_ZData] UNIQUE NONCLUSTERED ([Pid] ASC,[EntryID] ASC,[Date] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]GO
Test, found that the speed is much faster, reduce the risk of timeout.