Solved

Connection.Open fails

Posted on 2003-10-27
3
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

635 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