It seems this problem occurs when the wiring between the objectdatasource and
your DAL get out of synch. It actually cleared up for me as I continued to
work on my DAL, adding columns etc. and regenning, but if you're desperate to
just get it to work, you can "hardwire" the parameters to the failing method
with code similar to the following...
First define a OnInserting event in your ObjDataSource:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert" OnInserting="DS1Inserting"
SelectMethod="GetContacts" OnUpdating="DS1Updating"
TypeName="DataAccess.ptsContactsTableAdapters.ptsC ontactsTableAdapter"
UpdateMethod="Update">
Then put a method in your code to handle things manually. The routine below
wipes out the autogenerated parameters and reassigns the parameters to match
the assigned INSERT method in my DAL:
protected void DS1Inserting(object source, ObjectDataSourceMethodEventArgs e)
{
//Modify input params because objectdatasource is too dumb to figure
it out...
IDictionary paramsFromPage = e.InputParameters;
string last_name = e.InputParameters[0].ToString();
string first_name = e.InputParameters[1].ToString();
string email = e.InputParameters[2].ToString();
int role_id = Int32.Parse(e.InputParameters[3].ToString());
string user_id = e.InputParameters[4].ToString();
paramsFromPage.Clear();
paramsFromPage.Add("last_name", last_name);
paramsFromPage.Add("first_name", first_name);
paramsFromPage.Add("email", email);
paramsFromPage.Add("role_id", role_id);
paramsFromPage.Add("user_id", user_id);
}
"tparks69" wrote:
I get the error:
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method
'Insert' that has parameters: last_name, first_name, email, role_id, user_id,
modified_by, modified_date
when my application is trying to insert a record from a formview.
It works fine for delete, update, but insert just keeps failing. I have
removed the OldValuesParameterFormatString="original_{0}" from the
objectdatasource as suggested many places... this is how the update and the
delete came to work, but insert is still messed up. How to debug this? When
I put breakpoints into my data access layer (autogenerated by the designer)
they don't even break. They don't break for update or delete either so where
the heck is it running the code to update and delete? This is FRUSTRATING,
anyone got any answers?