Marcos Buarque
Marcos Buarque

Reputation: 3418

Can't establish SQL Server connection from VS 2008

I am sorry if this sounds like a silly question, but I have googled for a while for a solution and no success. I am trying to establish a connection from VS 2008 to SQL Server. I am trying to use an user that my web application has been successfuly using to access the database from in its connection string. But when doing it from VS 2008, it tells me "Login failed for use 'xxxxxx'". I am currently in the "Add Connection" window. I have chosen the datasource and server name, fulfilled username and password for SQL Server Authentication. Do I have to set specific permissions for this user? Do I need to allow a VS 2008 user in SQL Server? Thanks.

Upvotes: 2

Views: 1251

Answers (5)

Marcos Buarque
Marcos Buarque

Reputation: 3418

I have found the solution for this problem. My Visual Studio would pull automatically something like MACHINENAME\SQLEXPRESS. As it was pulled automatically, I did not bother taking a closer look at it. I finally realized the connection string that worked for me in my other application was .\SQLESXPRESS. When I entered it in Visual Studio, it did work. Thank you all for the help.

Upvotes: 2

SqlRyan
SqlRyan

Reputation: 33934

Are you trying to specify the username and password to connect with in the connection string - ALA:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

This actually uses SQL Authentication, not Integrated (Windows) authentication. What you might be looking for is this:

Data Source=myServerAddress;Initial Catalog=myDataBase;Trusted_Connection=True;

This would log into the database as the use running Visual Studio. Notice that the username/password aren't specified here - it uses the current Windows identity - in your case, that's the user running Visual Studio.

Upvotes: 0

DerX
DerX

Reputation:

You can test your SQL connection by connecting using LINQPad, Often find this solves problems with connections to new SQL Server instances at my workplace. http://www.linqpad.net/

Upvotes: 0

Matthew Talbert
Matthew Talbert

Reputation: 6048

With Visual Studio, you're connecting through a "remote" connection, even though they're on the same machine. With Server Management Studio, you're connecting through a named pipe probably. You need to change the SQL configuration so that it allows remote connections. Here are instructions for how to do it.

Upvotes: 0

Russell Steen
Russell Steen

Reputation: 6612

Do you have SQL Server Management Studio Express Installed? if so try connecting as the same user through that interface. This will isolate your problem a bit.

Upvotes: 0

Related Questions