System.Data.SqlClient.SqlException

Possible Errors under SqlException

Error 1:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) at .Net SqlClient Data Provider

Solution:

  • Check the Server name

Error 2
Cannot insert the value NULL into column 'EmpID', table 'Employees'; column does not allow nulls. INSERT fails. The statement has been terminated. at .Net SqlClient Data Provider

Solution:
  • Pass the value for the EmpID column while inserting data into the table.


Error 3

Could not find stored procedure 'Save_Employee_Details'. at .Net SqlClient Data Provider

Error 4
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32). at .Net SqlClient Data Provider

Error 5
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at .Net SqlClient Data Provider

Error 6
Violation of PRIMARY KEY constraint 'PK_EmpID'. Cannot insert duplicate key in object 'Employee'. The duplicate key value is (SAL1315N64W). The statement has been terminated. at .Net SqlClient Data Provider