User-2071549094 posted
Hi expert,
I am getting the above error. Not sure if it is because DAO class and the Service class cannot mixed together.
Cos I am putting in the Service class method together in my DAO class to try thing out.
However, I need to inherit the Service class interface - IWCFService1 so am not sure if this is giving me the error ?
public class ePMTDAO : IWCFService1
{
SqlConnection pcon = new SqlConnection(ConfigurationManager.AppSettings["EPMT"]);
// my DAO class
internal DataTable BindEmployee(string search, string searchby)
{
SqlCommand cmd = new SqlCommand("eDNSN_SP_BindEmployee", con);
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Search", search);
cmd.Parameters.AddWithValue("@Searchby", searchby);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
con.Close();
return dt;
}
// My WebService method
internal void InsertUserRequestForm(RequestOrder req)
{
// string Result;
con.Open();
//SqlCommand cmd = new SqlCommand("ePMT_SP_UpdateEPMTRequest", con);
SqlCommand cmd = new SqlCommand("ePMT_Sp_SaveEMPTRequest", con);
//cmd.Parameters.AddWithValue("@action", action);
cmd.Parameters.AddWithValue("@epmtNumber", req.EMPTId);
cmd.Parameters.AddWithValue("@iSGGID", req.InitiatorSGGID);
....
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
}
Furthermore, when I tried to call this WebService method in my button event firing, it says not in the current context :(
protected void btnSave_Click(object sender, EventArgs e)
{
if (Request.QueryString["EPMTID"] != null)
{
RequestOrder req = new RequestOrder();
InsertUserRequestForm(req); // error here
Hope someone can advise me.
Do I have to put the webservice's method in another new class ?