C#.net中的web服务问题

C#.net中的web服务问题,c#,webservice-client,C#,Webservice Client,我正在创建web服务,以便在客户端应用程序中获取员工详细信息。为此,我遵循了以下步骤: 员工财产类别: public class EmployeeProperty { #region class Members. private string _employeeid; private string _employeename; #endregion #region class property. public string Employe

我正在创建web服务,以便在客户端应用程序中获取员工详细信息。为此,我遵循了以下步骤:

员工财产类别:

public class EmployeeProperty
{
    #region class Members.
    private string _employeeid;
    private string _employeename;   
    #endregion

    #region class property.

    public string EmployeeID
    {
      get { return _employeeid; }
      set { _employeeid = value; }
    }

    public string EmployeeName
    {
      get { return _employeename; }
      set { _employeename = value; }
    }
雇员类别:

public DataSet GetEmployeeById(EmployeeProperty employee)
{
  SqlConnection conn = new SqlConnection(connStr);    
  conn.Open();   

  // building the command
  SqlCommand oCommand = new SqlCommand("GetEmployeeById", conn);
  oCommand.CommandType = CommandType.StoredProcedure;

  // Parameters 
  SqlParameter paraemployeeId = new SqlParameter();
  paraemployeeId.ParameterName = "@employeeId";
  paraemployeeId.SqlDbType = SqlDbType.VarChar;
  paraemployeeId.Size = 15;
  paraemployeeId.Direction = ParameterDirection.Input;
  paraemployeeId.Value = employee.EmployeeID;
  oCommand.Parameters.Add(paraemployeeId);

  // Adapter and DataSet
  SqlDataAdapter oAdapter = new SqlDataAdapter();

  oAdapter.SelectCommand = oCommand;
  DataSet oDataSet = new DataSet();

  try
  {       
    oAdapter.Fill(oDataSet, "Employee");

    if (oDataSet.Tables[0].Rows.Count > 0)
    {
      employee.EmployeeID = oDataSet.Tables[0].Rows[0]["Emp_ID"].ToString();
      employee.EmployeeName = oDataSet.Tables[0].Rows[0]["Emp_Name"].ToString();         
      return oDataSet;
    }
    else
    {
      throw new ApplicationException("Business object not found.");
    }
  }
  catch (Exception oException)
  {       
    throw;
  }
  finally
  {
    conn.Close();
  }
}
Web服务类:

public class EmployeeWebService : System.Web.Services.WebService
{

[Webmethod]
public DataSet GetEmployeeById(EmployeeProperty employee)
{
    DataSet ds = new DataSet();
    EmployeeDAL empdal=new EmployeeDAL();
    return empdal.GetEmployeeById(employee);
}
}
从客户端应用程序:

    webservice .EmployeeWebService empweb = new webservice .EmployeeWebService();       

    EmployeeProperty empproperty = new EmployeeProperty();         

    string empid = Txtempid.Text;

    empproperty.EmpID = empid;

    empweb.GetEmployeeById(empproperty);

    Txtempid.Text = empproperty.EmployeeID;

    Txtempname.Text = empproperty.EmployeeName;

    ....like this other values should display…..but not displaying the employee name in the text box its showing empty   value...

   What i done is correct????pls help its not working...how can i achieve it.

您没有使用WS-Server返回的
数据集

empweb.GetEmployeeById(empproperty);

上面的行返回一个包含查询数据的
数据集。

Ok你的意思是说ds=empweb.GetEmployeeById(empproperty);然后,如何在此处填充employeeproperty类成员..例如显示empname txtempname.text=ds.empname….如何执行此操作???dataset.tables(“tablename”).rows(0).item(“FieldName”).tostringtxtEmpname.Tex=ds.tables[0]。rows[0][“EmployeeName”].Tostring();它的显示,但我不想以这种方式empname属性自动应poup。任何帮助请???->PradeepGB:我知道,无论如何感谢回复..请阅读我目前的评论,我正在寻找一些替代方法