Asked by:
'ObjectDataSource' could not find a non-generic method that has parameters some parameters

Question
-
User2139087810 posted
Plz help, i got the following error when i insert new record using DetailsView and Oracle Procedures.
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'InsertSurvey' that has parameters: DESCRIPTION, startDate, endDate, ISOPEN, SURVEYID, START_DATE, END_DATE.
in app_code folder SurveyDataAccess.cs file is
public static int InsertSurvey( string description, DateTime startDate, DateTime endDate, int isOPEN) { int rowsAffected = 0; using (OracleConnection connection = ConnectionManager.getSohaibOracleConnection()) { OracleCommand command = new OracleCommand("INSERTSURVEY", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("P_DESCRIPTION", OracleDbType.Varchar2, 50).Value = description; command.Parameters.Add("P_START_DATE", OracleDbType.Date).Value = startDate; command.Parameters.Add("P_END_DATE", OracleDbType.Date).Value = endDate; command.Parameters.Add("P_ISOPEN", OracleDbType.Int32).Value = isOPEN; rowsAffected = command.ExecuteNonQuery(); } return rowsAffected; }
and CreateSurvey.aspx file is
<fieldset> <legend>Creat a Survey</legend> <asp:Label ID="lblSurveyResult" runat="server"></asp:Label> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="InsertSurvey" SelectMethod="getAllSurvey" TypeName="SurveyDataAccess"> <InsertParameters> <asp:Parameter Name="description" Type="String" /> <asp:Parameter Name="startDate" Type="DateTime" /> <asp:Parameter Name="endDate" Type="DateTime" /> <asp:Parameter Name="isOPEN" Type="Int32" /> </InsertParameters> </asp:ObjectDataSource> <asp:DetailsView ID="SurveyDetailsView" runat="server" DataSourceID="ObjectDataSource1" Height="50px" onmodechanging="SurveyDetailsView_ModeChanging" Width="222px"> <Fields> <asp:CommandField ShowInsertButton="True" /> </Fields> </asp:DetailsView> </fieldset>
and Procedure in Oracle is:
CREATE OR REPLACE PROCEDURE insertSurvey ( p_DESCRIPTION in survey.description%TYPE, p_START_DATE in survey.start_date%TYPE, p_END_DATE in survey.end_date%TYPE, p_ISOPEN in survey.isopen%TYPE ) AS BEGIN INSERT INTO SURVEY ( DESCRIPTION, START_DATE, END_DATE, ISOPEN ) VALUES ( p_DESCRIPTION, p_START_DATE, p_END_DATE, p_ISOPEN) ; COMMIT; END ;
Please help me on this issue or suggest detailed alternate. thanx.
Thursday, January 31, 2013 8:30 AM
All replies
-
User1938476581 posted
ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'InsertSurvey' that has parameters: DESCRIPTION, startDate, endDate, ISOPEN, SURVEYID, START_DATE, END_DATE.Hi,
You can try adding OldValuesParameterFormatString="original_{0}" in objectdatasource like this
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="InsertSurvey" OldValuesParameterFormatString="original_{0}" SelectMethod="getAllSurvey" TypeName="SurveyDataAccess">
For detailed information you can refer here
http://dotnetspidor.blogspot.com/2008/10/objectdatasource-could-not-find-non_26.html
http://stackoverflow.com/questions/10691916/objectdatasource-objectdatasource-could-not-find-a-non-generic-method-insert
Hope it can help you.
Thursday, January 31, 2013 9:36 PM -
User2139087810 posted
negtive. the default set value of ObjectDataSource is {0} and i made changes according to your instruciton but got same error.
Friday, February 1, 2013 1:36 PM -
User2139087810 posted
as you can see, theese two parameters "START_DATE & END_DATE." are automatically adding while i m not adding these. this is the main issue.
Saturday, February 2, 2013 1:50 AM