Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Some odd results from ObjectDataSource

Author  Topic 

Zeke
Starting Member

1 Post

Posted - 2009-03-09 : 15:55:59
Hello. I've been working on a small application in ASP.NET which, among other things, stores some information about contacts. I am using SQL Server 2008 express. I have a table with a few child tables to store contact information. I have used visual web developer express to create some strongly typed data sets and I am using an ObjectDataSource object to retrieve and modify the data in the table.

I can view the data fine but when I go to insert, update or delete, I get an error along the lines of:

quote:

ObjectDataSource 'contactDetailsDataSource' could not find a non-generic method 'Update' that has parameters: First_Name, Last_Name, Job_Title, Company, Spouse, Children, Gender, Birthday, Anniversary, Notes, original_ContactID, Original_First_Name, Original_Last_Name, Original_Job_Title, Original_Company, Original_Spouse, Original_Children, Original_Gender, Original_Birthday, Original_Anniversary, [First Name], [Last Name], Name, [Job Title].


The definition of the object's UpdateParameters (as generated in the aspx file by the ObjectDataSource configure wizard) is:


<UpdateParameters>
<asp:Parameter Name="First_Name" Type="String" />
<asp:Parameter Name="Last_Name" Type="String" />
<asp:Parameter Name="Job_Title" Type="String" />
<asp:Parameter Name="Company" Type="String" />
<asp:Parameter Name="Spouse" Type="String" />
<asp:Parameter Name="Children" Type="String" />
<asp:Parameter Name="Gender" Type="String" />
<asp:Parameter Name="Birthday" Type="DateTime" />
<asp:Parameter Name="Anniversary" Type="DateTime" />
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="Original_ContactID" Type="Int32" />
<asp:Parameter Name="Original_First_Name" Type="String" />
<asp:Parameter Name="Original_Last_Name" Type="String" />
<asp:Parameter Name="Original_Job_Title" Type="String" />
<asp:Parameter Name="Original_Company" Type="String" />
<asp:Parameter Name="Original_Spouse" Type="String" />
<asp:Parameter Name="Original_Children" Type="String" />
<asp:Parameter Name="Original_Gender" Type="String" />
<asp:Parameter Name="Original_Birthday" Type="DateTime" />
<asp:Parameter Name="Original_Anniversary" Type="DateTime" />
</UpdateParameters>


Inspection at runtime by adding a few breakpoints and digging into the input parameters collection shows that four additional parameters have been added. I have no clue where they are coming from or why it thinks they should be there. These are present in my code, however and are column names returned from the select query for the same table adapter. The query has the form:


SELECT Anniversary, Birthday, Children, Company, ContactID, FirstName AS [First Name], Gender, JobTitle AS [Job Title], LastName AS [Last Name], FirstName + ' ' + LastName AS Name, Notes, Spouse FROM Contacts WHERE (ContactID = @ContactID)


I notice the order is arbitrary and the columns are not in the same order as they are in the schema for the dataset.

I am rambling a bit but I'm unsure as to the origin of the problem and I am trying to give as much information as might be required. Similar results happen with delete and insert operations. Any useful feedback would be fantastic.

EDIT: I have resolved this by removing the column aliases from my select query. No idea why this would be screwing it up but it is now passing only the parameters that it should and not introducing any of its own.
   

- Advertisement -