allanmark
asked on
ObjectDataSource UpdateMethod fails
Greetings all
I am trying to update a table via the UpdateMethod of teh ObjectDataSource. I am getting this error: "ObjectDataSource 'spousalODS' could not find a non-generic method 'SpousalODS_Update' that has ........."
I have googled this but can not find a clear answer - soem feeling is that each and every field has to be specified. My data is coming froma formview which contaisn (currently) 52 fields. Do I have to type in each as a parmeter for the UpdateMethod?
In advance, thanks!!!
allanmark
I am trying to update a table via the UpdateMethod of teh ObjectDataSource. I am getting this error: "ObjectDataSource 'spousalODS' could not find a non-generic method 'SpousalODS_Update' that has ........."
I have googled this but can not find a clear answer - soem feeling is that each and every field has to be specified. My data is coming froma formview which contaisn (currently) 52 fields. Do I have to type in each as a parmeter for the UpdateMethod?
In advance, thanks!!!
allanmark
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you show complete error message
ObjectDataSource UpdateMethod needs to be a method of BusinessLogic.Business, just as the SelectMethod, "GetCouple" is a method of BusinessLogic.Susiness.
Then, depending on the type returned from the ObjectDataSource's Select Method, the Update Method should take a single parameter of the same type, or have a parameter for every field in your FormView.
Also, set the OldValuesParameterFormatSt ring to "{0}" on your ObjectDataSource.
Then, depending on the type returned from the ObjectDataSource's Select Method, the Update Method should take a single parameter of the same type, or have a parameter for every field in your FormView.
Also, set the OldValuesParameterFormatSt
ASKER
Hi!
I've done the changes (see attached snippet) --- not sure how to code the updateparameter in the Source ( the result of the Select is a DataTable) -- can't find any parameter type equivalent for a DataTable!!!
srikanthreddyn143:
"ObjectDataSource 'spousalODS' could not find a non-generic method 'SpousalODS_Update' that has parameters: C_Surname, C_Mar_Status, C_Wed_Anniv, C_Email, C_Active, ....."
I've done the changes (see attached snippet) --- not sure how to code the updateparameter in the Source ( the result of the Select is a DataTable) -- can't find any parameter type equivalent for a DataTable!!!
srikanthreddyn143:
"ObjectDataSource 'spousalODS' could not find a non-generic method 'SpousalODS_Update' that has parameters: C_Surname, C_Mar_Status, C_Wed_Anniv, C_Email, C_Active, ....."
SOURCE:
<asp:ObjectDataSource ID="spousalODS" runat="Server" SelectMethod="GetCouple" TypeName="BusinessLogic.Business"
OnSelected="spousalODS_Selected" OnSelecting="spousalODS_Selecting" UpdateMethod="SpousalODS_Update" OldValuesParameterFormatString="{0}" >
<SelectParameters >
<asp:QueryStringParameter Name="CoupleId" DbType="int32" Direction="Input" />
</SelectParameters>
<UpdateParameters>
WHAT GOES HERE ??
</UpdateParameters>
</asp:ObjectDataSource>
public static void SpousalODS_Update(DataTable dtCouple)
{
// Whatever we need to do here.
.................
}
public static DataTable GetCouple(int coupleId)
{
DataTable dtOurCouple = new DataTable();
dtOurCouple = DataAccess.ReturnCouple(coupleId);
return dtOurCouple;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Went through the tuts - makes a bit more sense now.
I'm just not looking forward to enetring 50+ parameters (which coudl grow to 75!!!
I'm just not looking forward to enetring 50+ parameters (which coudl grow to 75!!!
If you're application is simple enough and you don't need a Business Layer, you can use the ObjectDataSource to bind directly to a Strongly Typed DataAdapter (like those created in Tutorial 1). If you are using Stored Procedures, or your Select query doesn't contain any Joins, Visual Studio should be able to automaticallys generate Insert, Update, and Delete statements for you. So, if you set everything up right with Strongly Typed Data Sets, you could get a no code solution.
Of course, you could also try using straight SqlDataSources.
Of course, you could also try using straight SqlDataSources.
ASKER
Many thanks!! Apologoes for delay in closing.
ASKER
Had a look at the tutorial. I'm not usign the "Configure Data Source wizard" or the "OldValuesParameterFormatS
Open in new window