Click here to Skip to main content
15,400,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to connect my pc to another pc's sql server database with connection string of oledb

please help me this is my code

Provider=SQLOLEDB;Data Source=myIPADDress;Initial Catalog=test_db;Trusted_Connection=Yes

I got error like access denied

can you please help me.....

1 solution

You're getting access denied because the SQL Server is using your account credentials that you logged into Windows with and it doesn't trust you.

You need to get with the administrators of that SQL Server and find out what account username and password you need to use and provide that information in your connection string.
hareshdgr8 10-May-14 2:56am
but sir when I open sql server management studio I logged in with windows authentication mode that's why I not included userid and password in connectionstring

Please sir Help me,
Hope for answer ASAP.
Dave Kreskowiak 10-May-14 9:34am
Thanks for the 1-vote.

I'm telling you what the error message means. The SQL Server is telling you that the person running your code (since you used TrustedConnection = true) does not have permissions to the database you're trying to connect to.

It's that simple.

If your machine and the target machine are NOT in a domain environment (Active Directory) each machine maintains it's own user account database. If the SQL machine does not trust your machines account database, it's not going to work.

Also, if the account you're using does not have permissions to the database (it will NOT by default) you have to add those permissions.

Yes, you can have permissions to connect to the SQL server, but NOT have permissions to connect to the database itself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900