Converted from SqlDataSource to ObjectDataSource, causing grief

xXMaxxyXx

New Member
I have created a data access layer in my web app which uses ObjectDataSource instead of SqlDataSource. I have a FormView to update some data in my database. In my old asp.net code I had something like:\[code\]<asp:SqlDataSource ID="sdsTradeDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ForexDB %>" SelectCommand="usp_GetTrade" SelectCommandType="StoredProcedure" UpdateCommand="usp_UpdateTrade" UpdateCommandType="StoredProcedure" <SelectParameters> <asp:ControlParameter Name="tradeId" ControlID="grdTrades" PropertyName="SelectedDataKey.Value" /> </SelectParameters> <UpdateParameters> <asp:ControlParameter Name="tradeId" ControlId="frmTrade" PropertyName="SelectedValue" /> </UpdateParameters></asp:SqlDataSource>\[/code\]Which worked fine. I have replaced the SqlDataSource with this:\[code\]<asp:ObjectDataSource id="srcTrade" TypeName="DatabaseComponent.DBUtil" SelectMethod="GetTrade" UpdateMethod="UpdateTrade" runat="server"> <SelectParameters> <asp:QueryStringParameter Name="tradeId" QueryStringField="tradeId" /> </SelectParameters> <UpdateParameters> <asp:ControlParameter Name="tradeId" ControlId="frmTrade" PropertyName="SelectedValue" /> </UpdateParameters></asp:ObjectDataSource>\[/code\]But now I get this error when I click the Update button in my FormView:\[quote\] Exception Details: System.InvalidOperationException: ObjectDataSource 'srcTrade' could not find a non-generic method 'UpdateTrade' that has parameters: symbol, pctAccountRisked, tradeSetupId, lotsPerUnit, initialStopPrice, tfCode, MAEPips, MFEPips, tradeGrade, executionGrade, tradeTypeId, comment, tradeId.\[/quote\]In my DBUtil class I have this for UpdateTrade:\[code\]public void UpdateTrade( int tradeId, string symbol, decimal pctAccountRisked, string tradeSetupId, decimal lotsPerUnit, decimal initialStopPrice, string tfCode, int MAEPips, int MFEPips, int tradeGrade, int executionGrade, string comment){ SqlCommand cmd = new SqlCommand("usp_UpdateTrade"); cmd.Parameters.AddWithValue("@tradeId", tradeId); cmd.Parameters.AddWithValue("@symbol", symbol); cmd.Parameters.AddWithValue("@pctAccountRisked", pctAccountRisked); cmd.Parameters.AddWithValue("@tradeSetupId", tradeSetupId); cmd.Parameters.AddWithValue("@lotsPerUnit", lotsPerUnit); cmd.Parameters.AddWithValue("@initialStopPrice", initialStopPrice); cmd.Parameters.AddWithValue("@tfCode", tfCode); cmd.Parameters.AddWithValue("@MAEPips", MAEPips); cmd.Parameters.AddWithValue("@MFEPips", MFEPips); cmd.Parameters.AddWithValue("@tradeGrade", tradeGrade); cmd.Parameters.AddWithValue("@executionGrade", executionGrade); cmd.Parameters.AddWithValue("@comment", comment); UpdateTable(cmd, "trade");}\[/code\]and this for GetTrade:\[code\]public DataTable GetTrade(int tradeId){ SqlCommand cmd = new SqlCommand("usp_GetTrade"); cmd.Parameters.AddWithValue("@tradeId", tradeId); return FillDataTable(cmd, "trade");}\[/code\]Please help!
 
Top