Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't connect to SQL database

Status
Not open for further replies.

mrkan

Programmer
Oct 30, 2006
39
US
I am doing simple Console Application, trying to connect to database and then to print records... whatever...
I am failing to connect to database.

I am sure my code is correct, and my connection string is right. I copied it from "Server Explorer" properties where I am successfully seeing all the tables and fields.
I was googling this question and I figured it's about granting permission to my app to access sql server? Microsoft is suggesting to use permview.exe, but they for some reason think we all know where it is an how to use it. I couldn't find it on my machine. And, then... why would I need to set permissions if I am providing login and pass in my connection string? this is doesn't have any sense to me. I have VS2005.

Please somebody help me with this.

here is my code:
Code:
string ConnectionString = @"Network Library=DBMSSOCN;Data Source=servername;Initial Catalog=dbtest;User ID=xxx;Password=xxx;";
SqlConnection thisConnection = new SqlConnection(ConnectionString);
thisConnection.Open();               //it fails here
....

This is the error message:
Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top