Return Value in Web Method RRS feed

  • Question

  • User1997423929 posted
            public String attendance_shift_details(string pno, string frm_date, string to_date)
                SqlConnection con = new SqlConnection();
                con.ConnectionString = ConfigurationManager.ConnectionStrings["newconn"].ToString();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "select OffDay1,OffDay2,Saturday_Half,ShiftDuty,DivisionName,DepartmentName,SectionName,Intime,Outtime,Shift from App_EM where Pno='"+pno+"'";
                cmd.Connection = con;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds, "App_EM");
                if (Convert.ToBoolean(ds.Tables[0].Rows[0]["ShiftDuty"]) == true)
                    SqlCommand cmd1 = new SqlCommand();
                    cmd1.CommandText = "select Shift,Intime,OutTime,DayWeek from App_SM where Pno='"+pno+"' and Date between '"+frm_date+"' and '"+to_date+"' order by Date asc";
                    cmd1.Connection = con;
                    SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                    DataSet ds1 = new DataSet();
                    da1.Fill(ds1, "App_SM");
                return JsonConvert.SerializeObject(ds, Newtonsoft.Json.Formatting.Indented);

    I have two dataset (i.e. ds and ds1). If my "if condition" will true then I want to return ds1 value otherwise it  will return ds value. Pls help me to do this.

    Saturday, January 5, 2019 3:47 AM

All replies