I have a stored procedure in mysql and I am calling it via a method and objectdatasourc e. I have two select methods. One that gets a list of employees and the other that gets one specific employee by passing the employee id via a parameter.
I have two gridviews, one for displaying all employees and one for displaying one employee record. The user should be able to enter the employee id in the textbox and the gridview should display the employee's record. My code is working for displaying all employees but not for displaying one specific employee. The code compiles but does not display any info. Here is my code:
[code=asp]
<asp:objectdata source id="ObData2" runat="server" dataobjecttypen ame="EmpData" typename="Emplo yee" selectmethod="g etEmployee" ><selectparamet ers>asp:control parameter controlid="empl oyeeid" name="eId" propertyname="t ext" type="string" /></selectparameter s>
[/code]
[code=asp]
<asp:gridview id="GridView2" action="databin d" runat="server" datasourceid="O bData2"datakeyn ames="EmployeeI D" allowpaging="Tr ue" autogenerateedi tbutton="True" autogeneratecol umns="True"empt ydatatext="No Records" allowsorting="T rue" >
[/code]
[code=cpp]
[DataObjectMetho d(DataObjectMet hodType.Select)]
public void getEmployee(str ing eId)
{
MySqlCommand cmd = new MySqlCommand();
try
{
DB_Connection conn = new DB_Connection() ;
cmd.Connection = (MySqlConnectio n)conn.DBConnec t();
cmd.CommandText = "getEmploye e";
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("EMPLOYEEID ", eId);
cmd.ExecuteNonQ uery();
}[/code]
I have two gridviews, one for displaying all employees and one for displaying one employee record. The user should be able to enter the employee id in the textbox and the gridview should display the employee's record. My code is working for displaying all employees but not for displaying one specific employee. The code compiles but does not display any info. Here is my code:
[code=asp]
<asp:objectdata source id="ObData2" runat="server" dataobjecttypen ame="EmpData" typename="Emplo yee" selectmethod="g etEmployee" ><selectparamet ers>asp:control parameter controlid="empl oyeeid" name="eId" propertyname="t ext" type="string" /></selectparameter s>
[/code]
[code=asp]
<asp:gridview id="GridView2" action="databin d" runat="server" datasourceid="O bData2"datakeyn ames="EmployeeI D" allowpaging="Tr ue" autogenerateedi tbutton="True" autogeneratecol umns="True"empt ydatatext="No Records" allowsorting="T rue" >
[/code]
[code=cpp]
[DataObjectMetho d(DataObjectMet hodType.Select)]
public void getEmployee(str ing eId)
{
MySqlCommand cmd = new MySqlCommand();
try
{
DB_Connection conn = new DB_Connection() ;
cmd.Connection = (MySqlConnectio n)conn.DBConnec t();
cmd.CommandText = "getEmploye e";
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("EMPLOYEEID ", eId);
cmd.ExecuteNonQ uery();
}[/code]
Comment