Click here to Skip to main content
15,911,715 members
Home / Discussions / Article Writing
   

Article Writing

 
Question[Message Deleted] Pin
sonicryu8-Nov-07 6:04
sonicryu8-Nov-07 6:04 
AnswerRe: Some simple questions.(share) Pin
Mircea Grelus8-Nov-07 6:41
Mircea Grelus8-Nov-07 6:41 
AnswerRe: Some simple questions.(share) Pin
Pete O'Hanlon8-Nov-07 9:26
mvePete O'Hanlon8-Nov-07 9:26 
GeneralRe: Some simple questions.(share) Pin
Rajesh R Subramanian14-Nov-07 20:58
professionalRajesh R Subramanian14-Nov-07 20:58 
GeneralRe: Some simple questions.(share) Pin
Xmen Real 24-Nov-07 18:38
professional Xmen Real 24-Nov-07 18:38 
AnswerRe: Some simple questions.(share) Pin
Llasus8-Nov-07 14:14
Llasus8-Nov-07 14:14 
QuestionSome simple examples of .NET Web Services Pin
ssTahoe7-Nov-07 12:15
ssTahoe7-Nov-07 12:15 
AnswerRe: Some simple examples of .NET Web Services Pin
Pete O'Hanlon8-Nov-07 9:46
mvePete O'Hanlon8-Nov-07 9:46 
Working with data is pretty simple. Here's a sample called GetMyData in a web service class called MyWebClass. It retrieves a load of data from some data source and populates a generic collection before returning it to the client.
[WebMethod]
public List<CustomClass> GetMyData()
{
  List<CustomClass> custClass = new List<CustomClass>();
  // Do something to get the data from the database and put it into a data reader
  //...
  while (myDataReader.Read())
  {
    CustomClass item = new CustomClass();
    item.Id = myDataReader.GetInt32(0);
    item.Name = myDataReader.GetString(1);
    custClass.Add(item);
  }
  return custClass;
}
Compile your webservice and add a webreference to it in your calling code (we'll call it WebRef here). The signature for this method will look like this public CustomClass[] GetMyData(); because web services can't return generic lists, but they can return arrays of classes so .NET marshals your list class to an array of objects. In your client code, do this:
WebRef.MyWebClass cl = new WebRef.MyWebClass();
CustomClass[] items = cl.GetMyData();
I'm doing this off the top of my head, so I apologise if the syntax isn't 100% correct here. Note - if you want to use a generic list on the client side, you can do this:
List<CustomClass> list = new List<CustomClass>();
list.AddRange(cl.GetMyData());


Deja View - the feeling that you've seen this post before.

QuestionWPF PropertyGrid Pin
Bartosz Bien6-Nov-07 11:08
Bartosz Bien6-Nov-07 11:08 
AnswerRe: WPF PropertyGrid Pin
Pete O'Hanlon7-Nov-07 11:12
mvePete O'Hanlon7-Nov-07 11:12 
QuestionCity or Zip database listing nearest cities Pin
cliffr19544-Nov-07 19:38
professionalcliffr19544-Nov-07 19:38 
AnswerRe: City or Zip database listing nearest cities Pin
Pete O'Hanlon5-Nov-07 9:56
mvePete O'Hanlon5-Nov-07 9:56 
AnswerRe: City or Zip database listing nearest cities Pin
Paul Conrad28-Nov-07 17:05
professionalPaul Conrad28-Nov-07 17:05 
GeneralRe: City or Zip database listing nearest cities Pin
Jon Sagara5-Dec-07 8:49
Jon Sagara5-Dec-07 8:49 
QuestionA nice to have Pin
Sk8tz1-Nov-07 20:31
professionalSk8tz1-Nov-07 20:31 
AnswerRe: A nice to have Pin
Whytespot2-Nov-07 11:25
Whytespot2-Nov-07 11:25 
GeneralRe: A nice to have Pin
Paul Conrad3-Nov-07 7:54
professionalPaul Conrad3-Nov-07 7:54 
GeneralRe: A nice to have Pin
Sk8tz6-Nov-07 18:47
professionalSk8tz6-Nov-07 18:47 
QuestionAutocomplete arcticle without Webservice Pin
jebin k27-Oct-07 6:15
jebin k27-Oct-07 6:15 
QuestionOpening run dialog from taskbar Pin
kjfarley26-Oct-07 15:12
kjfarley26-Oct-07 15:12 
AnswerRe: Opening run dialog from taskbar Pin
Scott Dorman26-Oct-07 16:51
professionalScott Dorman26-Oct-07 16:51 
QuestionTAB CONTROL Pin
PeriyasamyRamachandran26-Oct-07 4:37
PeriyasamyRamachandran26-Oct-07 4:37 
AnswerRe: TAB CONTROL Pin
Scott Dorman26-Oct-07 16:53
professionalScott Dorman26-Oct-07 16:53 
GeneralRe: TAB CONTROL Pin
PeriyasamyRamachandran26-Oct-07 18:19
PeriyasamyRamachandran26-Oct-07 18:19 
QuestionTracking and Tracing Information System Pin
ramez8518-Oct-07 13:41
ramez8518-Oct-07 13:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.