Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql server 2008 connection string error

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???

like image 506
sbs Avatar asked Sep 07 '26 17:09

sbs


1 Answers

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).

like image 152
marc_s Avatar answered Sep 11 '26 22:09

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!