siri Posted June 8, 2008 Share Posted June 8, 2008 Hi ,I am getting following error :"ObjectDataSource 'o1' could not find a non-generic method 'getrecord' that has parameterswhen using the objectdatasource control. Here is the code.**************************************************************<asp:GridView ID = "g1" DataKeyNames = "empid" AutoGenerateSelectButton="true" DataSourceID="a1" runat = "server" /> <asp:GridView ID = "g3" DataKeyNames = "empid" DataSourceID = "o1" runat = "server" /> <asp:AccessDataSource ID = "a1" runat = "server" DataFile = "~/App_Data/db1.mdb" SelectCommand = "select * from employees" /> <asp:ObjectDataSource ID = "o1" runat = "server" TypeName = "Class1" SelectMethod = "getrecord"> <SelectParameters> <asp:ControlParameter ControlID = "g1" Type = "Int32" /> </SelectParameters> </asp:ObjectDataSource>*******************************************************Here is the class1.vb-----------------------------------------------------Public Class Class1 Public Function getrecord(ByVal empid As Integer) As OleDbDataReader Dim con As New OleDbConnection con.ConnectionString = "provider = microsoft.jet.oledb.4.0; data source = " _ & HttpContext.Current.Server.MapPath("~/App_Data/db1.mdb") Dim query As String = "select * from emloyees where empid = @empid" Dim cmd As New OleDbCommand(query, con) cmd.Parameters.AddWithValue("@empid", empid) con.Open() Return cmd.ExecuteReader(CommandBehavior.CloseConnection) End FunctionEnd Class------------------------------------------------------------------ Link to comment Share on other sites More sharing options...
pr.nimbalkar Posted July 28, 2008 Share Posted July 28, 2008 Hey, use this code , it works definately <asp:ObjectDataSource ID = "o1" runat = "server" TypeName = "Class1" SelectMethod = "getrecord"> <SelectParameters> <asp:ControlParameter ControlID = "g1" Name="empid" Type = "Int32" /> </SelectParameters> </asp:ObjectDataSource> Hi ,I am getting following error :"ObjectDataSource 'o1' could not find a non-generic method 'getrecord' that has parameterswhen using the objectdatasource control. Here is the code.**************************************************************<asp:GridView ID = "g1" DataKeyNames = "empid" AutoGenerateSelectButton="true" DataSourceID="a1" runat = "server" /> <asp:GridView ID = "g3" DataKeyNames = "empid" DataSourceID = "o1" runat = "server" /> <asp:AccessDataSource ID = "a1" runat = "server" DataFile = "~/App_Data/db1.mdb" SelectCommand = "select * from employees" /> <asp:ObjectDataSource ID = "o1" runat = "server" TypeName = "Class1" SelectMethod = "getrecord"> <SelectParameters> <asp:ControlParameter ControlID = "g1" Type = "Int32" /> </SelectParameters> </asp:ObjectDataSource>*******************************************************Here is the class1.vb-----------------------------------------------------Public Class Class1 Public Function getrecord(ByVal empid As Integer) As OleDbDataReader Dim con As New OleDbConnection con.ConnectionString = "provider = microsoft.jet.oledb.4.0; data source = " _ & HttpContext.Current.Server.MapPath("~/App_Data/db1.mdb") Dim query As String = "select * from emloyees where empid = @empid" Dim cmd As New OleDbCommand(query, con) cmd.Parameters.AddWithValue("@empid", empid) con.Open() Return cmd.ExecuteReader(CommandBehavior.CloseConnection) End FunctionEnd Class------------------------------------------------------------------ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.