sql server 2008 connection string error

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

sql-server-2008
connection-string
asked on Stack Overflow Nov 16, 2010 by sbs • edited Nov 18, 2010 by sbs

2 Answers

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

answered on Stack Overflow Nov 16, 2010 by marc_s
0

Yo,

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

answered on Stack Overflow Nov 16, 2010 by Manvi

User contributions licensed under CC BY-SA 3.0