7

It installed automatically with Visual Studio 2010 Ultimate. I didn't create any users for the server or ANYTHING.

I'm using:

string connectionString = @"Server=.\SQLEXPRESS;Database=SportsStore;Trusted_Connection=yes;";

I get error that authentication failed. So the server is being found, but my credentials are wrong. What would the default login and password be?

Edit: Still not working! :(

Here's my connection string:

string connectionString = @"Server=.\SQLEXPRESS;Database=SportsStore;Integrated Security=SSPI;";

And the error message:

Cannot open database "SportsStore" requested by the login. The login failed. Login failed for user 'ToshibaLaptop\Sergio'.

Sergio Tapia
  • 40,006
  • 76
  • 183
  • 254

5 Answers5

5

If you are using SQL Server authentication you could try the username sa and blank password but I am not sure whether this is by default. Integrated Windows authentication should work, so you should be able to connect with your Windows account:

string conn = "Data Source=.\SQLExpress;Initial Catalog=mydb;Integrated Security=SSPI;";
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • The server installer asked me for a password, I'm using sa as user (login) and the password given and I can connect me to the server. – William Ardila Nov 23 '17 at 06:03
3

You probably should not connect using Sql Server Authentication.

Log in as an Administrator on the box, connect using Integrated Windows Authentication, and you should be a system admin.

Dave Markle
  • 95,573
  • 20
  • 147
  • 170
1

The error message indicates that SQL Server can't open the database. I think you're successfully authenticating, but having a problem connecting to the database. Is the database available?

You can do a test by changing the database to master in your connection string. If that succeeds, then you're problem is related to the database. I understand that you may get other errors, but the test is to confirm that you can login to SQL Server.

bobs
  • 21,844
  • 12
  • 67
  • 78
1

For me SQL Server (SQLEXPRESS) service was disabled so it was throwing the error. After enabling the service SSMS is working fine

  1. Goto Run command and type services.msc and click on OK button
  2. Services window will open. Check the status of SQL Server (SQLEXPRESS) service
  3. If the service is not running, then start the service

Now try logging in again in the SSMS.

Kira
  • 1,403
  • 1
  • 17
  • 46
0

In SQL 2008 if you use the defaults there won't be a SQL Server user only Windows Authentication will be enabled - and it will only work for the user that installed the application would have access via their Active Directory authentication.

u07ch
  • 13,324
  • 5
  • 42
  • 48