Sql server 2008 connection string error

I know this is a pretty standard problem ... but can't figure it out.

So here is what I want to do:

I want to connect to a local sql. \ SQLEXPRESS server by using Windows authentication. I can log in using SQL Server Management Studio.

My connection string looks like this:

string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Integrated Security=SSPI";

he gives me an error:

Cannot open database "Sports" requested by the login. The login failed.

so i tried:

string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Trusted_Connection=True";

this gives me:

Invalid authorization specification

Then I tried:

string connStr = "Provider=SqlOleDB;Data Source=.\\SQLExpress; Initial Catalog=Sports; Integrated Security=True";

it returns:

No error message available, result code: DB_E_ERRORSOCCURRED(0x80040E21).

Any ideas?

Updates: I forgot to mention, I use windows 7 of the virtual machine working with SQL Server Express Express. Is there anything in common with a virtual machine?

+3
source share
2 answers

Are you familiar with http://www.connectionstrings.com ??

- :

Server=.\\SQLExpress;Database=Sports;Integrated Security=SSPI

, ( ).

+2

,

IDE? VS2008? SqlServer Configuration Manager.

0

Source: https://habr.com/ru/post/1775292/


All Articles