Page view counter

Method Not Found error when inserting with Linqdatasource

Last post 08-12-2008 10:19 AM by CybrEnergy. 8 replies.

Sort Posts:

  • Method Not Found error when inserting with Linqdatasource

    08-04-2008, 9:05 AM
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

    I've been trying to figure this one out and it's driving me nuts!  For some reason when using the Linqdatasource with a Formview I keep getting the following error when trying to do an insert:

    I am using Visual Studio.NET 2008 SP1 BETA with the 3.5 Framework SP1 BETA.  Am I missing something obvious here?

     

     System.MissingMethodException: Method not found: 'System.Object System.Web.UI.WebControls.Parameter.GetValue(System.Object, Boolean)'.


    Generated: Mon, 04 Aug 2008 12:40:10 GMT

    System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.MissingMethodException: Method not found: 'System.Object System.Web.UI.WebControls.Parameter.GetValue(System.Object, Boolean)'.
    at System.Web.UI.WebControls.LinqDataSourceView.MergeDictionaries(Object dataObjectType, ParameterCollection reference, IDictionary source, IDictionary destination, IDictionary destinationCopy)
    at System.Web.UI.WebControls.LinqDataSourceView.BuildInsertDataObject(Object table, IDictionary values)
    at System.Web.UI.WebControls.LinqDataSourceView.ExecuteInsert(IDictionary values)
    at System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback)
    at System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation)
    at System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
    at System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e)
    at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
    at System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e)
    at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
    at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
    at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    --- End of inner exception stack trace ---
    at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at ASP.sellyourhome_aspx.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
      
        <asp:LinqDataSource ID="ProspectDataSource" runat="server" ContextTypeName="Business.ReiSiteBuilderDataContext" EnableInsert="true"
    TableName="Prospects">
    </asp:LinqDataSource>
    <asp:FormView runat="server" ID="ProspectFormView" DataSourceID="ProspectDataSource"
    DefaultMode="Insert">
    <InsertItemTemplate>
    Name:
    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
    <br />
    PhoneNumber:
    <asp:TextBox ID="PhoneNumberTextBox" runat="server" Text='<%# Bind("PhoneNumber") %>' />
    <br />
    Email:
    <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
    <br />
    AdSourceId:
    <asp:TextBox ID="AdSourceIdTextBox" runat="server" Text='<%# Bind("AdSourceId") %>' />
    <br />
    SellingPrice:
    <asp:TextBox ID="SellingPriceTextBox" runat="server" Text='<%# Bind("SellingPrice") %>' />
    <br />
    Address1:
    <asp:TextBox ID="Address1TextBox" runat="server" Text='<%# Bind("Address1") %>' />
    <br />
    Address2:
    <asp:TextBox ID="Address2TextBox" runat="server" Text='<%# Bind("Address2") %>' />
    <br />
    City:
    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
    <br />
    State:
    <asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>' />
    <br />
    Zipcode:
    <asp:TextBox ID="ZipcodeTextBox" runat="server" Text='<%# Bind("Zipcode") %>' />
    <br />
    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
    Text="Insert" />
     <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
    CommandName="Cancel" Text="Cancel" />
    </InsertItemTemplate>
    </asp:FormView>
     
  • Re: Method Not Found error when inserting with Linqdatasource

    08-06-2008, 11:27 PM

    Hi CybrEnergy,

    There's no problem with the code you provided. Also, I tested the code on my machine and everything worked well. Therefore, I am wondering whether there's any problem in the table. Based on my experience, this is probably caused by the lack of a primary key. I want you to clarify whether you have a primary key in this table? If not, you need to set it.

    I will wait for your reply and get back to you.

    Thanks.

    David Qian
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Method Not Found error when inserting with Linqdatasource

    08-07-2008, 7:32 AM
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

     The table definitely has a primary key.  I can insert data directly into my table via SQL management studio and it generates the identity key just fine.  Table has a few foreign keys to other tables with data also.

    I'm wondering if this could be some kind of a configuration issue?

  • Re: Method Not Found error when inserting with Linqdatasource

    08-07-2008, 7:39 AM
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

     It also seems that deletes and updates result in the same error.  So it seems like any operation from the Linqdatasource results in that same error "method not found".

  • Re: Method Not Found error when inserting with Linqdatasource

    08-07-2008, 8:03 AM
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

     Lastly, I can do this in the codebehind with no problems (below).  The problem is specific with the Linqdatasource and trying to let it do the auto inserts/updates/deletes.  I have had the problem with both a Formview and a Radgrid (telerik).  So I really think something isn't working with the datasource.

      

    Dim oneProspect As New Business.Prospect
    
            With oneProspect
    
                .CompanyId = CInt(Session("CompanyId"))
                .AdSourceId = 1
                .Name = "Direct Test"
                .Address1 = "123 Main Street"
                .City = "Test"
                .State = "MD"
                .Zipcode = "12345"
                .PhoneNumber = "111-333-4444"
                .Email = "test@test.com"
                .SellingPrice = 123.45
    
            End With
    
            Dim db As New Business.ReiSiteBuilderDataContext
            db.Prospects.InsertOnSubmit(oneProspect)
            db.SubmitChanges()
     
  • Re: Method Not Found error when inserting with Linqdatasource

    08-07-2008, 10:43 PM

    Hi CybrEnergy,

    The problem confused me much. Actually, LinqDataSource can do automatic insert/update/delete for you. Also, I tested it on my machine and everything worked pretty well. Although you can resolve it in code-behind, I don't think it's the best solution for this problem. Using LinqDataSource is the most suitable for this scenario since you need to write more unnecessary code.

    I have two more questions need you to clarify? Did you write the LinqDataSource and FormView code manually or let it generate automaticlly? If you write it maually, I suggest you to generate it automaticlly which will avoid the careless errors.

    The other question is that, since you said you have foreign keys in this table, did you insert a proper record? As you know, you only can insert a value which should be in the value collection related to the primary key. You can also take a try on a table with no foreign keys and see whether it works for you.

    Thanks.

    David Qian
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Method Not Found error when inserting with Linqdatasource

    08-08-2008, 7:33 AM
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

     I know that the Linqdatasource can do the automatic operations, that's what I was trying to do initially.  The code behind was an example that I can infact persist data to the database with the same information that I was trying to use with the Linqdatasource and Formview.

    I have tried to configure both the Linqdatasource and Formview automatically and manually.  Both yield the same errors.

    The data inserted was infact proper and like I said, it worked fine in the test code I showed in the code behind.  I have even tried this in a new project against a different database with a smaller table that has no primary keys.  Same results.

     It seems like no matter what, my Linqdatasource won't work.  I guess maybe I need to re-apply my service packs or something.  I wish somebody could offer some additional troubleshooting methods or insight as to what exactly this error means.

  • Re: Method Not Found error when inserting with Linqdatasource

    08-11-2008, 12:23 AM

    Hi CybrEnergy,

    It's so strange for this. I think there must has some difference bewteen your page and mine.

    Please provide both the page and source code, including the table schema so I can re-project it on my machine.

    Thanks.

    David Qian
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Method Not Found error when inserting with Linqdatasource

    08-12-2008, 10:19 AM
    Answer
    • Loading...
    • CybrEnergy
    • Joined on 09-26-2002, 10:11 AM
    • Mount Airy, MD
    • Posts 94
    • Points 381

     Since the RTM version of the Visual Studio 2008 and .NET Framework 3.5 SP1s came out yesterday I went ahead and replaced the Beta copies of both on my system.  After doing that everything seems to work fine.  There must have been something quirky on my system related to the Beta that was causing the odd behavior.

Page 1 of 1 (9 items)