Failed to Connect SQLClient - InfoPath Dev
in

InfoPath Dev

Failed to Connect SQLClient

Last post 04-03-2016 03:35 AM by htalebi. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-19-2010 11:50 PM

    Failed to Connect SQLClient

     I'm using InfoPath 2010 and write code vs. I try to retrieve the records from SQL server and update the form's field but system prompt the following error when execute the code "objConn.Open()"

     

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

    System.Security.SecurityException was unhandled by user code
      Message="Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
      Source="mscorlib"
      StackTrace:
           at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
           at System.Security.PermissionSet.Demand()
           at System.Data.Common.DbConnectionOptions.DemandPermission()
           at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
           at System.Data.SqlClient.SqlConnection.Open()
           at Absence_Request_Form.DBConnect.QueryDataSet(String strSQL)
           at Absence_Request_Form.FormCode.abFromDate_Changed(Object sender, XmlEventArgs e)
           at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
           at Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnAfterChange(DataDOMEvent pDataDOMEvent)
     

    Please advice and suggest the solution.

    Thank you.

    Regards,
    Mink ^^

  • 01-04-2011 07:48 AM In reply to

    Re: Failed to Connect SQLClient

    Hi there -- this code will require your form be full trust. You may want to revise your code and create a data connection in InfoPath first, then modify the SQL for that data connection. Then your form can be domain trust.
    Hilary Stoupa

  • 07-18-2011 02:02 PM In reply to

    Re: Failed to Connect SQLClient

    I have the same problem if any one found the solution please let u sknow

  • 01-08-2012 09:18 PM In reply to

    Re: Failed to Connect SQLClient

    Hi Hilary,

    could you please explain more about your suggested fix? You mean to say, we can use Data Connection that we created through UI in code? 

    Below is my exception message that i am receiving when opening connection through C# code on Form load event:

    [System.Security.SecurityException] = {"Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."} 

     

    Below is my connection string and code block i am using in my code:

    using (SqlConnection conn = new SqlConnection("Data Source=systemname\\dbname;Initial Catalog=SharePoint_DB;User ID=admin;Password=Pass01*;Integrated Security=true;"))

    {

    conn.Open();

    conn.Close();

    }

     I need this issue to be fixed very deadly, please kindly help me.

    thanks

    raj 

     

     

    Thank you
    Raj
  • 04-03-2016 03:35 AM In reply to

    Re: Failed to Connect SQLClient

    If you are still searching for a solution 3 years later, here is it :) in infopath designer goto: File -> Form options -> Security and Trust -> then uncheck 'Automatically determine security level' and check 'Full trust' voila!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.