Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
https://www.dropbox.com/s/l45p5v4jp0qjjvb/Screenshot%202014-05-11%2001.49.50.png[^]

i had maked a method of get data like this
C#
public List<datalist7> getdata(string id)
{
  SqlConnection con = new SqlConnection(@"Data Source=saba-PC;Initial Catalog=bcounts;Integrated Security=True");
  con.Open();
  SqlCommand cmd = new SqlCommand("Select Compcode,Acct_sub0,Acct_Desc from GI_sub0 where Compcode='" + id + "'", con);
  SqlDataReader rdr = cmd.ExecuteReader();
  List<datalist7> data = new List<datalist7>();
  if (rdr.HasRows)
  {
    // while (rdr.Read())
    //  data.Add(new dataclass7(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2)));
  }
  con.Close();
  return data;
}
        
[DataContract]
public class datalist7
{
  [DataMember]
  public string val1 { get; set; }
  [DataMember]
  public string val2 { get; set; }
  [DataMember]
  public string val3 { get; set; }
  [DataMember]
  public string val4 { get; set; }
  [DataMember]
  public string val5 { get; set; }
  [DataMember]
  public string val6 { get; set; }
  [DataMember]
  public string val7 { get; set; }
  public datalist7(string v1, string v2, string v3, string v4, string v5, string v6, string v7)
  {
    val1 = v1;
    val2 = v2;
    val3 = v3;
    val4 = v4;
    val5 = v5;
    val6 = v6;
    val7 = v7;
  }
}

but whhen i am testing webservice and giving an id it will give me response like
NAME VALUE TYPE
(return) length=0 WcfService2.datalist7[]
Whats the matter?
Posted
Updated 10-May-14 22:57pm
v2

1 solution

Note that you have comment the item adding code of your service

C#
if (rdr.HasRows)
{
  // while (rdr.Read())
  //  data.Add(new dataclass7(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2)));
}


if this is actual code of service you will not get any results.

it should be soemthing like below

C#
if (rdr.HasRows)
{
  while (rdr.Read())
    data.Add(new dataclass7(rdr.GetString(0), rdr.GetString(1), rdr.GetString(2), "", "", "", ""));
}


otherwise your service code and WcfTestClient application working fine. As per WcfTestClient response, there is no matching records found for '001' go to sql server and run below statement
SQL
Select Compcode,Acct_sub0,Acct_Desc from GI_sub0 where Compcode='001'

you will not get any records for sure.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900