3

I know this is a quite standard issue... but can't figure it out..

So here's what i want to do:

I want to connect to my local sql server .\SQLEXPRESS by windows authentication. I can login by using the SQL Server Management Studio.

My connection string is like this:

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

it throws 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";

it 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'm using virtual machine windows 7 running the sql server 2010 express. Is there anything to do with the virtual machine???

2 Answers 2

2

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

I would try something like:

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

That should work, I hope (no need to specify a provider and all that stuff).

Sign up to request clarification or add additional context in comments.

1 Comment

i tried most the combinations from the connectionstrings.com website. And if i didn't add the provider, it gives me an error telling me that i need to specify the provider. This connection string works fine when i connect to the server, but not works fine when i want to connect to the local.
0

Yo,

Do u use some IDE? Like VS2008? First, try restart SqlServer in your Configuration Manager.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.