473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

webservice struct return

Hello,

I have a question about returning Array of structs from a web service.

I am querying a database and building a datatable. I am trying to fill
an array of structs with the data and return it to my presentation
layer. I can see my records in the datatable, but the structs all have
the same data. Here is the code.
public kbReturnResults[] GetKB(string group, string category, string
description)
{
KB objKB = new KB();
objKB.Group = group;
objKB.Category = category;
objKB.Description = description;
int number;
KBManager kbMgr = new KBManager();
kbReturnResults[] kb = null;
number = int.Parse(kbMgr.Count(objKB));
DataTable objDataTable = kbMgr.Lookup(objKB);
kb = new kbReturnResults[number];
foreach(DataRow row in objDataTable.Rows)
{
for (int i = 0; i < number; i++)
{
foreach(DataColumn dataCol in objDataTable.Columns)
{
if(dataCol.ColumnName.Equals("KBID"))
{
kb[i].KBID = "KBID "+i.ToString();
}
if(dataCol.ColumnName.Equals("Author"))
{
kb[i].Author = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("Link"))
{
if(row[dataCol].Equals(" "))
{
kb[i].Link = "Null";
}
else
{
kb[i].Link = row[dataCol].ToString();
}
}
if(dataCol.ColumnName.Equals("Description"))
{
kb[i].Description = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("Solution"))
{
if(row[dataCol].Equals(""))
{
kb[i].Solution = "Null";
}
else
{
kb[i].Solution = row[dataCol].ToString();
}
}
if(dataCol.ColumnName.Equals("Group"))
{
kb[i].Group = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("Date"))
{
kb[i].KBDate = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("Subject"))
{
kb[i].Subject = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("View"))
{
kb[i].KBView = int.Parse(row[dataCol].ToString());
}
if(dataCol.ColumnName.Equals("FileName"))
{
kb[i].FileName = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("KBDate"))
{
kb[i].KBDate = row[dataCol].ToString();
}
if(dataCol.ColumnName.Equals("Category"))
{
kb[i].Category= row[dataCol].ToString();
}

}
}
}

return kb;
}

Nov 17 '05 #1
0 1412

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I am writing a webservice that has a method which requires an array of a custom object. I am having problems understanding why a few things are occuring My webservice looks like this ...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
0
by: Thijs | last post by:
Hi, I am developing both a webservice and a Windows Forms webservice client. After I've deployed my webservice to the webserver I update my webservice reference in my client application, but the...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i donīt want to filter the return value of the method, i have to pass a new instance of the...
3
by: Frank H. | last post by:
Hi, in my webservice I have a Webmethod wich returns a list of Objects to my C++ Application. C# code: public class Contact { public string FirstName;
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
1
by: Salvador | last post by:
Hi, I am migrating a webservice to .net 2.0, I am keeping exactly the same interface but the client that generated the autogenerated class with the previous webservice seems to not recognize the...
0
by: =?Utf-8?B?SmFtZXM=?= | last post by:
Hi I have 2 types of structs eg struct A and struct B struct A has property contains a arraylist of struct B, the getter and setter for the property does not contain any logic, basically reference...
1
by: carled | last post by:
Hi all. New here and new to .net from classic asp. I have to access an xml-rpc webservice in .net and it's making my brain fry trying to get it all set up. I'm most comfortable with vb, but I can...
4
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.