Olaide Azeez

Olaide Azeez

  • 1.7k
  • 67
  • 12.9k

Retrieving Multiple data in web service

Jul 17 2016 10:19 AM
The code below refers: How can I display the result in gridview at the consumer site.
 
public class dclinic
{
public string ddays { get; set; }
public string dperiod { get; set; }
}

[WebMethod]

public List<dclinic> clinicPeriod(string clinic)
{
string sq = "select Days,Period from clinicperiod where clinic = @clinic";

gap.Open();
SqlCommand cq = new SqlCommand(sq, gap);
cq.Parameters.AddWithValue("@clinic", clinic);
SqlDataReader reader = cq.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
gap.Close();
List<dclinic> rlist = new List<dclinic>();
for (int i = 0; i < dt.Rows.Count; i++)
{
dclinic dcc = new dclinic();
dcc.ddays = dt.Rows[i]["days"].ToString();
dcc.dperiod = dt.Rows[i]["period"].ToString();
rlist.Add(dcc);
}

return rlist;

}

Answers (2)