Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. WCF data transfer

WCF data transfer

Scheduled Pinned Locked Moved WCF and WF
helpquestioncsharpwcfsecurity
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bindum31
    wrote on last edited by
    #1

    Dear all, When i use Dataset to retrieve data from WCF service to client according to the following process it works perfectly:

    public DataSet GetJobs()
    {
    SqlConnection cn = new SqlConnection(@"Data Source=dotnet02\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True");
    DataSet ds = new DataSet();
    SqlDataAdapter da = new SqlDataAdapter("Select * from jobs", cn);
    da.Fill(ds, "jobs");
    return ds;
    }

    But when i want to return LIST<Job>instead of Dataset in the follwing way i can't access the method from Client side though after modification of my service code i take the reference of my service from the client as before.

    public List<Job> GetJobs()
    {
    SqlConnection cn = new SqlConnection(@"Data Source=dotnet02\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True");
    string sqlstat = "select * from jobs";
    SqlCommand cmd = new SqlCommand(sqlstat, cn);
    SqlDataReader dr = cmd.ExecuteReader();
    List<Job> allJobs = new List<Job>();
    Job jobObj;
    while (dr.Read())
    {
    jobObj = new Job();
    jobObj.Description = dr["job_desc"].ToString();
    jobObj.MinLevel = Convert.ToInt32(dr["min_lvl"]);
    jobObj.MaxLevel = Convert.ToInt32(dr["max_lvl"]);
    allJobs.Add(jobObj);
    }
    return allJobs;
    }

    I can't figure out the problem! How can i do this? Any help will be highly appreciated.

    R 1 Reply Last reply
    0
    • B bindum31

      Dear all, When i use Dataset to retrieve data from WCF service to client according to the following process it works perfectly:

      public DataSet GetJobs()
      {
      SqlConnection cn = new SqlConnection(@"Data Source=dotnet02\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True");
      DataSet ds = new DataSet();
      SqlDataAdapter da = new SqlDataAdapter("Select * from jobs", cn);
      da.Fill(ds, "jobs");
      return ds;
      }

      But when i want to return LIST<Job>instead of Dataset in the follwing way i can't access the method from Client side though after modification of my service code i take the reference of my service from the client as before.

      public List<Job> GetJobs()
      {
      SqlConnection cn = new SqlConnection(@"Data Source=dotnet02\SQLEXPRESS;Initial Catalog=pubs;Integrated Security=True");
      string sqlstat = "select * from jobs";
      SqlCommand cmd = new SqlCommand(sqlstat, cn);
      SqlDataReader dr = cmd.ExecuteReader();
      List<Job> allJobs = new List<Job>();
      Job jobObj;
      while (dr.Read())
      {
      jobObj = new Job();
      jobObj.Description = dr["job_desc"].ToString();
      jobObj.MinLevel = Convert.ToInt32(dr["min_lvl"]);
      jobObj.MaxLevel = Convert.ToInt32(dr["max_lvl"]);
      allJobs.Add(jobObj);
      }
      return allJobs;
      }

      I can't figure out the problem! How can i do this? Any help will be highly appreciated.

      R Offline
      R Offline
      Rutvik Dave
      wrote on last edited by
      #2

      Because when you use DataSet, there is no problem in serialization. but when you use your own class 'Job', then you have to define the serialization. Have you applied the attributes like, [Data Contract] to the class [Data Memeber] to the property variables also it will be more clear, if you specify the erorr message, that you are getting.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups