sarpay
4/24/2015 - 12:26 PM

[mssql] SQL Server Connection

[mssql] SQL Server Connection

================================================================================
Connection Strings
================================================================================
Local:
<add name="HoldRite_DbConn_LOCAL" connectionString="Data Source=.\MSSQLSERVER2012;Initial Catalog=db_name; Integrated Security=True; MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/>

Remote:
<add name="HoldRite_DbConn_INTERNAL" connectionString="SERVER=mssql1202.wc2\inst2; database=db_name; uid=abcd; pwd=1234;" providerName="System.Data.SqlClient"/>

================================================================================
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
================================================================================
Follow the steps mentioned below.

1. Start >> All Programs >> Microsoft SQL Server >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Network Configuration >> Protocols for MSSQLSERVER >> "Enable" both “TCP/IP” and "Named Pipes".

2. Start >> Run >> type “services.msc” >> Restart SQL service.

================================================================================
Cannot open database requested by the login. The login failed.
Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’.
================================================================================
1. Open Management Studio
2. Connect to Server
3. Expand 'Security'
4. Expand 'Logins'
5. Right click on 'NT AUTHORITY\SYSTEM'
6. Click 'Properties'
7. Select 'Server Roles'
8. Check 'sysadmin'
9. Click OK

--- OR ---

1.) Start >> All Programs >> Microsoft SQL Server >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services
2.) Double click on the SQL Server >> Select the built-in account as "Local System"

================================================================================
Login failed for user 'IIS APPPOOL\ASP.NET v4.0 Classic'
================================================================================
1. Open Management Studio
2. Connect to Server
3. Expand 'Security'
4. Right Click on 'Users' > Add New User
5. Add 'IIS APPPOOL\ASP.NET v4.0 Classic' as User Name and Login Name
6. Select 'Default Schema' as 'dbo'
7. Go to 'Membership' from left menu and select 'db_owner'
8. Click OK