Hope this helps you
[WebMethod]
public static List<record> GetData(string param)
{
SqlConnection con = new SqlConnection(@"ConnectionString");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT type,desc,num,ref,date FROM foo", con);
SqlDataReader dr = cmd.ExecuteReader();
List<record> records = new List<record>();
while (dr.Read())
{
records.Add(new Record() {
AccountType = dr.GetString(0),
PartDescription = dr.GetString(1),
PartNumber = dr.GetInt32(2),
OrderRef = dr.GetString(3),
TransactionDate = dr.GetDateTime(4)
});
}
dr.Close();
con.Close();
return records;
}</record></record></record>