Solved

Connection.Open fails

Posted on 2003-10-27
3
394 Views
Last Modified: 2010-04-16
Hi,

I am fairly new to programming in C#.  I am trying to connect to a database.  I keep getting an exception when trying to execute the connection.open method.  Any ideas?:


Unhandled Exception: System.Security.SecurityException: Request for the permission of type System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
   at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
   at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
   at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
   at System.Security.CodeAccessPermission.Demand()
   at System.Data.SqlClient.SqlConnectionString.Demand(SqlConnectionString constr)
   at System.Data.SqlClient.SqlConnection.Open()
   at BS.BST_Project.getAllProjectsFinancials()
   at BS.BST_Project.Main(String[] args)

The state of the failed permission was:
<IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
             version="1"
             AllowBlankPassword="False">
   <add ConnectionString="Data Source=XX.XX.XX.XXX;Initial Catalog=BST_DB;User Id=test;"
        KeyRestrictions=""
        KeyRestrictionBehavior="AllowOnly"/>
</IPermission>
0
Comment
Question by:aamir11
3 Comments
 

Expert Comment

by:paylett
ID: 9630821
It appears that your database requires a password, and you haven't supplied one. Check your connection string.
0
 
LVL 1

Accepted Solution

by:
aamir11 earned 0 total points
ID: 9633868
Actually I figured out the problem.  I was running the application from a mapped drive to a database on another server.  That was failing.  However if I ran the application from the same drive as sthe server was located on, it worked.  Not sure why but it did
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question