System.InvalidOperationException: ExecuteNonQuery: Connection Property Has Not Been Initialized

Why is my connection not being initialized?  It seems to me in my syntax I set it up as it should be.  How can I get around this so the connection will be initialized?  I am needing to have a re-usable function as the database parameter needs
to be passed into the connection string.
public static void DoSomething_Click()
string database = "1234";
OleDbConneciton olc = new OleDbConnection(AccessConnection(database));
olc.Open();
try
OleDbCommand command = new OleDbCommand();
command.CommandText = ATS;
command.CommandType = CommandType.Text;
command.ExecuteNonuery();
command.Dispose();
catch (Exception wtf) { Messagebox.show(wtf.ToString()); }
private static string AccessConnection(string database)
return string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\Test\\{0}.mdb", database);

You've set up a connection, and a command, but you didn't associate the two. The command you have set up needs to know what connection to use. You haven't set that up.
command.Connection = olc;

Similar Messages

  • The ConnectionString property has not been initialized random error

    Hi,
    Can someone please help me?
    I randomly get an error when running my website:
    The ConnectionString property has not been initialized.
    First time I run the web page it works. Second time it fails. Is this got anything to do with static methods?
    This is my code in DAL layer:
    ConStrings.cs
    public class ConStrings
    /// </summary>
    public static string PizzaDeliveryConnectionString
    get
    // get from PL web.config
    string myconnectionString = ConfigurationManager.ConnectionStrings["PizzaDeliveryConnectionString"].ConnectionString;
    return myconnectionString;
    public static SqlConnection GetPizzaDeliveryConnection()
    return new SqlConnection(PizzaDeliveryConnectionString);
    DLCustomer.cs
    public class DLCustomer
    static SqlConnection connString = DL.ConStrings.GetPizzaDeliveryConnection();
    public static DataSet GetCustomerByPhoneNumber(string phonenumber)//static is good for returing data from db
    DataSet ds = null;
    ds = new DataSet();
    try
    using (var connection = connString)//using doesn't require connection closed
    connection.Open();
    using (SqlCommand cmd = new SqlCommand("GetCustomerByPhoneNumber", connection))
    cmd.Connection = connection;
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@phonenumber", phonenumber);
    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
    da.Fill(ds, "CustomersTable");
    return ds;
    catch (SqlException ex)
    return ds;
    BUSINESS LAYER
    Customer.cs
    public class Customer
    private string phonenumber;
    private DL.DLCustomer customerData;
    public int CustomerId { get; set; }
    public string CustomerName { get; set; }
    public String PhoneNumber
    get
    return this.phonenumber;
    set
    this.phonenumber = value;
    if (this.PhoneNumber == "")
    throw new Exception("Please provide Tel ...");
    public Customer () // Default Constructor
    //An instance of the Data access layer!
    customerData = new DL.DLCustomer();
    /// Function Find customer. Calls the
    /// function in Data layer.
    /// It returns the details of the customer using
    /// customer ID via a Dataset to GUI tier.
    /// </SUMMARY>
    public static DataSet GetCustomerByPhoneNumber(Customer customer)
    if (customer.phonenumber == "")
    throw new Exception("Please provide phonenumber to search");
    DataSet data = null;
    data = DL.DLCustomer.GetCustomerByPhoneNumber(customer.phonenumber);
    return data;
    Presentation layer
    protected void btnOrder_Click(object sender, EventArgs e)
    Customer customer = new Customer();
    //string dt = Request.Form[txtDate.UniqueID];
    customer.PhoneNumber = txtPhoneNumber.Text;
    // ClassLibrary1.DbFunc1.GetCustomerByPhoneNumber(customer) ;
    rptCustomers.DataSource = Customer.GetCustomerByPhoneNumber(customer);
    rptCustomers.DataBind();
    web.config
    <configuration>
    <connectionStrings>
    <add name="PizzaDeliveryConnectionString" connectionString="Data Source=mycomp;Initial Catalog=PizzaDelivery;Integrated Security=True" providerName="System.Data.SqlClient" />
    </connectionStrings>

    Hi
    collie12,
    Since you develop in web page. Please try to use
    System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString;
    This requires references to System.Configuration.dll and System.Web.dll.
    WebConfigurationManager.ConnectionStrings Property gets the Web site's connection strings.
    Please also try to remove your static keyWords, it will have an effect on "using" statement.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • ExecuteReader:CommandText  property has not been initialized

    Hi,
    In my program, rptViewer is the object of class ReportViewer.
    When control goes to the line rptViewer.ShowDialog(), then it displays the system massage on sap that "ExecuteReader:CommandText  property has not been initialized". Please tell me the solution to remove this message.
    Regards
    Nisha

    Hi Nisha,
    The ReportViewer object is a .NET object from Microsoft and not part of the SBO SDK.
    Try reviewing the ReportViewer samples from Microsoft and compare them to your own code. The samples can be found here:
    http://www.microsoft.com/downloads/details.aspx?familyid=F38F7037-B0D1-47A3-8063-66AF555D13D9&displaylang=en
    Kind Regards,
    Owen

  • Exception calling "ExecuteNonQuery" with "0" argument(s): "CommandText property has not been initialized.

    I have CSV file  which has sdimiler  data I am inserting those  date to desinated table and while executing this  query mentioned below I get error mentioned in TITLE
    insert into SU_EDIT_DETAIL(EDIT_FUNCTION, TABLE_FUNCTION, CODE_FUNCTION, CODE_TYPE,CODE_BEGIN, CODE_END, EXCLUDE, INCLUDE_X, OP_NBR, TRANSCODE, VOID, YMDEFF, YMDEND, YMDTRANS)"
    select  $($line."EDIT_FUNCTION"),($line."TABLE_FUNCTION"), ($line."CODE_FUNCTION"),'DIAG', ($line."CODE_BEGIN"), ($line."CODE_END"),' ',' ',' ','MIS', 'C',' ',20141001, 99991231, 20131120 
    from dual where not exists(select * from SU_EDIT_DETAIL where (EDIT_FUNCTION = ($line."EDIT_FUNCTION") and TABLE_FUNCTION = ($line."TABLE_FUNCTION")
    and CODE_BEGIN= ($line."CODE_BEGIN") 
    and CODE_END= ($line."CODE_END")));
    commit;
    Vijay Patel

    This SQL appears to be Oracle PL/SQL.  You may want to post in the Oracle forum.  If you are habving issues with the ADO.NET objects then you need to supply more of your code.
    ¯\_(ツ)_/¯

  • The ConnectionString property has not been initialized

    for the line:adapter.Fill(datatable)this is for Visual Studio 2013here is the complete code:Public Class ClientsRelation
    Private Sub ClientsRelation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    TextBox1.Select()
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim result As DialogResult
    result = MessageBox.Show("Sure you Wanna Close ?", "Close?", MessageBoxButtons.YesNo)
    If result = System.Windows.Forms.DialogResult.Yes Then
    Me.Close()
    End If
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim IDNumber As Integer
    Dim datatable As New DataTable
    If (Me.TextBox1.Text = "") Then
    MsgBox("ID Number cannot be in blank", MsgBoxStyle.Critical, "Alert")
    Me.TextBox1.Select()
    Else
    IDNumber = Val(Me.TextBox1.Text)
    cmd.CommandType = CommandType.Text
    cmd.Connection = con
    End If
    Using con
    Dim adapter As New OleDb.OleDbDataAdapter("Select Clients.IDNumber, Clients.FirstName, Clients.LastName, Clients.Telephone, Clients.Email, Cars.VIN, Cars.ClientIDNumber, Cars.Make, Cars.Model, Cars.Color From Clients Inner Join Cars On Clients.IDNumber = Cars.ClientIDNumber Where IDNumber = " & TextBox1.Text & "", con) adapter.Fill(datatable)
    End Using
    If datatable.Rows.Count = 0 Then
    MsgBox("ID Number Not Found, Please Try Again", MsgBoxStyle.Critical, "Alert")
    Else
    Me.DataGridView1.DataSource = datatable
    End If
    End Sub
    End Class
    how do i fix this error?

    Also, you probably don't want to have it in a Using block if it is declared at the module level like that because it will get disposed and then you can't resuse it so it defeats the purpose of putting it in a module (which really isn't necessary
    anyway - better to put it in the using statement and end then connection when you are done with it).
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
    this form is part of like 20 other forms. i call the con.open at the start of the first form when it loads and i then i con.close when i exit the program. this way the connection is open the whole time for all the forms.

  • Error during project server 2013 The property or field 'StartDate' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    Hi sir,
    when I have try to fetch the value of project start date and finish date and some other field value , I have recived error message like The property or field 'StartDate' has not been initialized. It has not been requested or the request has not been
    executed. It may need to be explicitly requested.
    I have used client context for project server 2013.
    I have also load and execute query.but fail to resolve it Please suggest me and provide solution.
    vijay

    Hi,    
    If you use the Include<TSource> Method in the Load method, we will retrieve only the ids of items in this query, so
    the listItems.ListItemCollectionPosition will not be initialized.
    You can use the <ViewFields> tag in CAML Query to specify the field values to return with each item instead.
    Best regards
    Patrick Liang
    TechNet Community Support

  • "The property or field has not been initialized" Error, when debbuging app

    Hello,
    I'm  following the instructions of a dev book but I get the following error message when debugging the app.
    "The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."
    The code:
    var collListItems;
    $(document).ready(function () {
    getConfigValues();
    function getConfigValues() {
    var context = SP.ClientContext.get_current();
    var configList = context.get_web().get_lists().getByTitle('Configuration Values');
    var camlQuery = new SP.CamlQuery();
    collListItems = configList.getItems(camlQuery);
    context.load(collListItems);
    context.executeQueryAsync(onGetConfigValuesSuccess, onGetConfigValuesFail);
    function onGetConfigValuesSuccess() {
    var OrgLogoUrl;
    var OrgName;
    var listItemEnumerator = collListItems.getEnumerator();
    while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    var current = oListItem.get_item('Title');
    switch (current) {
    case 'OrganizationName':
    OrgName = oListItem.get_item('Value');
    break;
    case 'OrganizationLogoUrl':
    OrgLogoUrl = oListItem.get_item('Value');
    break;
    if (OrgName && OrgName.length > 0) {
    $('#DeltaPlaceHolderPageTitleInTitleArea').html(OrgName);
    $('.ms-siteicon-img').attr('title', OrgName);
    if (OrgLogoUrl && OrgLogoUrl.length > 0)
    $('.ms-siteicon-img').attr('src', OrgLogoUrl);
    else
    $('.ms-siteicon-img').attr('src', '../Images/AppLogo.png');
    function onGetConfigValuesFail(sender, args) {
    alert('Failed to get the Configuration Values. Error:' + args.get_message());
    What it have to do is to replace the Title and Site logo, using the "Title" and "Value" fields of the "Configuration Values" list.
    My dev environment: SharePoint online, Azure, VS2013 Ultimate (trial)
    I've tried to reach the author of the book but it's being 4 days and no response, maybe somebody here can help me.
    Thanks in advance.
    Jimmy

    Jaydeep, I don't get the values, see the HTML code below.
    <%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" Language="C#" %>
    <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%-- The markup and script in the following Content element will be placed in the <head> of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <!-- Add your CSS styles to the following file -->
    <link rel="Stylesheet" type="text/css" href="../Content/App.css" />
    <!-- Add your JavaScript to the following file -->
    <script type="text/javascript" src="../Scripts/App.js"></script>
    </asp:Content>
    <%-- The markup in the following Content element will be placed in the TitleArea of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
    KA Online Klas
    </asp:Content>
    <%-- The markup and script in the following Content element will be placed in the <body> of the page --%>
    <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div id="menu">
    <ul>
    <li><a href="../Lists/Configuration Values">Site Configuration</a></li>
    <li><a href="../Lists/Site Assets">Site Assets</a></li>
    </ul>
    </div>
    </asp:Content>

  • Csom error The property or field 'LoginName' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

    Hi sir,
    When I have get the value of project owner the error is occured
    The property or field 'LoginName' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    vijay

    Hi Vijay,
    The owner details are not loaded by default when you load all projects.
    You have to make sure the details of the project owner are loaded before you can access them:
    foreach (PublishedProject pubProj in projContext.Projects){
    User owner = pubProj.Owner;
    projContext.Load(owner);
    projContext.ExecuteQuery();
    Console.WriteLine(owner.LoginName);

  • Error code: 1 : 10  summary: Designtime cache has not been initialized

    I am getting this error at the time of deploying the the esb project at server.
    error code: 1 : 10
    summary: Designtime cache has not been initialized
    Please look in logs for following signs of failure. Fix them and restart. (a) Database access errors (b) ESB Bootstrap errors (c) OC4J class load errors (d) Product installation errors (e) Export ESB params and verify if host and port parameters are correct. Please contact Oracle Support if unable to fix the issue.
    Fix: -
    How I can fix this issue. If somebody know then please answer. I am waiting a postive reply for you people.

    HI,
    We also had this problem.
    But I have replaced the esb folder from my colleague's system and then I found in two files referring the system name in some configuration files, I have changed that to my system name. then it started working.
    --Khaleel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Kernel upgrade error:The license key library has not been initialized yet.

    We have updated the Solution manager with EHP1 kernel with latest patch55.<br>
    Operating system platform:OS/400.<br>
    We are getting error :The license key library has not been initialized yet.<br>
    We have gone through Note 982056(The license key library has not been<br>
    initialized yet) but after application restart we still are facing problem.<br>
    Also with old kernel(Patch 32) our system is working fine.<br>
    For SAP Router we need to do the kernel Upgrade.<br>
    Work process log:<br>
    *******************************************************************************************************************<br>
    ERROR => DlLoadLib()==DLENOACCESS - dlopen("/usr/sap/S01/SYS/exe/run/libsapcrypto.o") FAILED<br>
      "Could not load module /usr/sap/S01/SYS/exe/run/libsapcrypto.o.<br>
    Additional errors occurred but are not reported."  (errno=2,No such file or directory) [dlux.c       445]<br>
    N  *** ERROR => <br>
    ===...could not load SSF library /usr/sap/S01/SYS/exe/run/libsapcrypto.o .<br>
    The market place does not show any patch for SAP Crypto Library. To include the file libsapcrypto.o in ibm system i.<br>
    Regards,
    Prasad

    Hi Thomas,<br>
    I have applied the SAP Cryptographic Library IBM AIX for RS6000/Power mentioned in the note on system i.<br>
    The following changes are made:<br>
    In the instance profile,
    as4/ADDLIBPATH = /usr/sap/... is added.<br>
    ssf/name=SAPSECULIB<br>
    ssf/ssfapi_lib=<SAP Cryptographic software directory>/libsapcrypto.o<br>
    sec/libsapsecu=<SAP Cryptographic software directory>/libsapcrypto.o<br>
    I am facing similar error with directory run_sec
    Error log:
    ERROR => DlLoadLib()==DLENOACCESS - dlopen("/usr/sap/S01/SYS/exe/run_sec/libsapcrypto.o") FAILED<br>
      "Could not load module /usr/sap/S01/SYS/exe/run_sec/libsapcrypto.o.<br>
    Additional errors occurred but are not reported."  (errno=2,No such file or directory) [dlux.c       445]<br>
    N  *** ERROR => <br>
    ===...could not load SSF library /usr/sap/S01/SYS/exe/run_sec/libsapcrypto.o .<br>
    Regards,
    Prasad

  • ServletConfig has not been initialized

    I have a download servlet that I am working with (actually BalusC's servlet code that I have modified/broken). When I go to get the mime type of the file that I am sending by :
    String contentType = getServletContext().getMimeType(file.getName());I get this error.
    java.lang.IllegalStateException: ServletConfig has not been initialized
    I am overriding the init function so that I can pool database connections and load the root location of the downloadable files if that helps any.
    Thanks ,
    Chem E

    Thanks BalusC, turns out that I wasnt using super.init(config) in my init code. Lesson learned.
    By the way , could you educate further why database connection pooling in my init code is a terrible idea. I am using the glassfish connection pooling method. Here is my init code.
       @Override
        public void init(ServletConfig config) throws ServletException
            super.init(config);
            try
                // Look up the JNDI data source only once at init time
                Context envCtx = (Context) new InitialContext();
                datasource =
                        (DataSource) envCtx.lookup("jdbc/pooledConnections");
            catch (NamingException e)
                e.printStackTrace();
        }From that point on I just use this code to hand out connections as needed.
        private Connection getConnection() throws SQLException, SQLException
            return datasource.getConnection();
        }Thanks for your help,
    Chem E

  • ESB Error: Designtime cache has not been initialized

    Hi,
    I get following error when trying to deploy the ESB or even try to open the ESB Control:
    Designtime cache has not been initialized Please look in logs for following signs of failure. Fix them and restart. (a) Database access errors (b) ESB Bootstrap errors (c) OC4J class load errors (d) Product installation errors (e) Export ESB params and verify if host and port parameters are correct. Please contact Oracle Support if unable to fix the issue.
    Does any one knows what the problem is ? I tried restarting the Application server many times but this problem is not solved...

    Hi,
    First things I would check :
    - check connectivity between SOA and Dehydration DB
    - check if DB and DB listener are running
    - check in esb_parameter table from ORAESB schema if DT_OC4J_HOST and DT_OC4J_PORT point to the machine where ESB-DT is running
    - if you made a recent upgrade - have you also upgraded the DB schemas for esb and bpel ?
    Hope it helps
    Mihai

  • Build state machine has not been initialized

    Problems occurred when invoking code from plug-in: org.eclipse.core.resouces
    eclipse.buildId=M20100211-1343
    java.version=1.6.0_20
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=pt_BR
    Command-line arguments: -os linux -ws gtk -arch x86
    Error
    Wed Oct 20 08:19:22 BRST 2010
    Build state machine has not been initialized.
    It occurs when building the project and after the error happens once, it always happens
    to save the project.

    Problems occurred when invoking code from plug-in: org.eclipse.core.resouces
    eclipse.buildId=M20100211-1343
    java.version=1.6.0_20
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=pt_BR
    Command-line arguments: -os linux -ws gtk -arch x86
    Error
    Wed Oct 20 08:19:22 BRST 2010
    Build state machine has not been initialized.
    It occurs when building the project and after the error happens once, it always happens
    to save the project.

  • Adding custom webpart throwing Javascript error -The collection has not been initialized.

    Hi,
    I created a Javascript CSOM visual webpart and added to page. In the IE developer tools console, I am getting an error as below:
    "SCRIPT5022: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
    SP.Runtime.js, line 2 character 35853".
    My code is as below:
    <script type="text/javascript" src="../../_layouts/15/MicrosoftAjax.js"></script>
    <script type="text/javascript" src="../../_layouts/15/SP.Runtime.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.js"></script>
    <script type="text/javascript" src="../_layouts/15/sp.ui.controls.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/Rotator.js"></script>
    <script type="text/javascript" src="/_layouts/15/test/Scripts/bjqs-1.3.js"></script>
    <link rel="stylesheet" type="text/css" href="/_layouts/15/test/CSS/bjqs.css" />
    <SharePoint:FormDigest ID="FormDigestRotator" runat="server">
    </SharePoint:FormDigest>
    <div id="banner-fade">
    <ul id="carousel" class="bjqs">
    </ul>
    </div>
    // In Rotator.js
    $(document).ready(function () {
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadConfigData);
    function loadConfigData() {
    var clientcontext = new SP.ClientContext.get_current();
    var oweb = clientcontext.get_site().get_rootWeb();
    var olist = oweb.get_lists().getByTitle("LibName");
    var configquery = SP.CamlQuery.createAllItemsQuery();
    Allpictures = olist.getItems(configquery);
    clientcontext.load(Allpictures, 'Include(Title,ImgSubURL)');
    clientcontext.executeQueryAsync(Function.createDelegate(this, this.Configsuccess), Function.createDelegate(this, this.Configfailed));
    How to fix this javascript error? Due to this, the "Check-in" option is not working.
    Update: i believe the error is with "executeQueryAsync". How to fix this?
    Thanks

    Hi,
    I suggest you create a simple demo first, once it works, then add other customization into your project gradually. It will be easier to composite the correct code.
    Please apply the code below in your project for a try:
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    _spBodyOnLoadFunctionNames.push("callCSOM");
    var clientContext;
    var website;
    var str="";
    // Make sure the SharePoint script file 'sp.js' is loaded before your
    // code runs.
    function callCSOM()
    //alert("call");
    $("#Button1").click(function()
    ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");
    // Create an instance of the current context.
    function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();
    clientContext.load(website);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    function onRequestSucceeded() {
    str="website.get_title(): "+website.get_title();
    alert(str);
    function onRequestFailed(sender, args) {
    alert('Error: ' + args.get_message());
    </script>
    <input id="Button1" type="button" value="Run Code"/>
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

    hi sir,
    I have try to update task assignments using csom model.
     erro message ::The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested
     foreach (PublishedAssignment assignItem in item.Assignments)
                                Guid id =assignItem.Id;
                               cc.Load(assignItem, a => a.Resource,a=>a.PercentWorkComplete);
                               cc.ExecuteQuery();
                               EnterpriseResource er = cc.EnterpriseResources.GetByGuid(assignItem.Resource.Id);
                               cc.Load(item.Assignments,c=>c.Where(uu=>uu.Id==id).IncludeWithDefaultProperties( l=> l.Task.Assignments,l=>l.Work));
                               cc.ExecuteQuery();
                               er.Assignments.Single(ll => ll.Id == id).Work = "9";
                               cc.Load(er);
                               cc.ExecuteQuery();
                               StatusAssignmentCollection sac = er.Assignments;
                               sac.Update();
                               sac.SubmitAllStatusUpdates("hello vijay");
    vijay

    Hi Vijay,
    You didn't load the 'er.Assignments' collection.
    Make sure it's loaded and it should work
    Hope this helps

Maybe you are looking for