Connection string failing for SQL server 2012 - sql

I'm trying to connect to my db on my local machine with the following connection string and it fails for the following connection string
conn = new SqlConnection("Server=(local);DataBase=dnn6;Integrated Security=SSPI");
I'm using IIS 6 as my web server and when I open that page I get the following error.
Cannot open database "dnn6" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\demo'.
I'm using SQL Server 2012

The problem is that the IIS account being used to access SQL Server (IIS APPPOOL\demo) does not have access to it.
You need to either:
grant permission for the user IIS APPPOOL\demo to your SQL Server
use impersonation to connect to SQL Server with a user account that has access
use SQL Server Logins to access SQL Server using a named user (not recommended these days)

Related

Can't connect my desktop application to local SQL Server 2008 Express

I am using SQL Server authentication for login through SQL Server Management Studio and I can access SQL Server. However, my desktop application cannot establish a connection to the server. I use the following connection string:
Server=PC-ADMIN\SQLEXPRESS; Database= Cafe; User=name; Pwd=password;
Please help.

SQL Server error 18456 [duplicate]

This question already has answers here:
Login failed for user (Microsoft SQL Server, Error:18456) SQL Server 2005
(2 answers)
Closed 6 years ago.
windows unable to connect to SQL server with windows authentication mode I haven't created SQL authentication.Server name is AYAZ .Server is able to connect with Analysis and Reporting service but unable to connect with Database engine
Here is another suggestion:
SQL Server allows only SQL logins in the SQL Authentication mode. The logins are defined within SQL Server.
In short, if you want to use Window account to connect to SQL Server, connection string should not have user name and password. It would be something like below. Instead of username and password, we need to use “Integrated Security=SSPI”
Provider=SQLNCLI11.1;Data Source=SQLSERVER2016;Integrated Security=SSPI
For additional information: http://blog.sqlauthority.com/2016/02/17/sql-server-fix-error-18456-severity-14-state-6-login-failed-for-user/
Follow the below steps described here
Logon as a local administrator.
Stop the "SQL Server" service and run "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -m" (start SQL
Server in Local Only mode.)
Logon to SSMS from the server itself - no password required.
Add my own domain account as a Login, with sysadm server role.
Restart the SQL Server service

Cannot connect to sql server 2008 using JDBC

I have tried all the methods to connect to the server.I am using sql server 2008 on mixed authentication mode.I can login via the sql server management studio using the sa login.But when I try accessing the same db from my java program I get the following error:
SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:191d94bb-a55e-47a0-bb9f-b84638313cf4
This is my connectionstring:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl= "jdbc:sqlserver://localhost;databaseName=Northwind;user=sa;password=sa;";
I have accessed my database in the same way. One of my problems were that I hadn't enabled the port and IP for the database. Check these options in SQL Server Configuration Manager. Hope this helps =)

SQL Server 2008 erroneously returning SQL Authentication failed

I am attempting to connect to SQL via SQL authentication. On SQL Server I receive Login succeeded, yet via code I get Login failed for user 'geneva'. I verified the login in SSMS and am able to connect via Windows authetnication. The sql user has full rights. Tried via java/.net code, really unsure why I am unable to connect via SQL Auth.
Data Source=server;Initial Catalog=GenevaWorkflow;User ID=user;Password=password
The environment is SQL Server 2008/Windows 2008. Very frustrating being all I want is to connect via SQL authentication and SQL Server I set to mixed mode authentication.
Enable sql logins in server properties (from management studio) and restart sql server.

Sql server authentication Issue

In sql server 2005,
I could not connect to sql server in 'sql server Authentication' mode but i could connect in windows authentication mode.
The Username and password are also correct.
The Error says:
A connection was successfully established with the server, but then an error occured during the login process.(provider: shared memory provider, error:0-No process is on the other end of the pipe) (microsoft sql server: error:233)
May be the server is not configured to use both windows and sql server authentication modes