LabsResponse labresponse = new LabsResponse(); Lab[] labs = new Lab[1]; string cs = ConfigurationManager.ConnectionStrings["DatabaseContext"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { int i = 0; SqlCommand cmd = new SqlCommand("Select * from Labs where clinicNumber=" + clinicNumber, con); con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { labs[i].CategoryName =reader[0].ToString(); labresponse.Labs = labs; i++; } con.Close(); return labresponse;
public partial class LabsResponse : ServiceResponse { private Lab[] labsField; /// <remarks /> [System.Xml.Serialization.XmlArrayAttribute(IsNullable = true)] [System.Xml.Serialization.XmlArrayItemAttribute(Namespace = "http://schemas.datacontract.org/2004/07/Mayo.Cdans.Labs.Objects")] public Lab[] Labs { get { return this.labsField; } set { this.labsField = value; } } } when i a trying to assign value to labs[i].CategoryName it gives above mentioned error what can be done please help. thanks in advance.
labs[i].CategoryName =reader[0].ToString();
labs[i].CategoryName =Convert.ToString(reader[0]);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)