Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 4th, 2004, 03:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Arlington, TX, USA.
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default HELP - C# newbie question on variables & propertie

I have a class that is access a webservice that contains the stored
procedure that I am accessing but I do not know how to apply variables to the elements of the dataset so that I can access it in my property.
ANY help or direction would be appreciated. Thanks.

[u]Here is my class code</u>:

public class InvoiceList
{
private int iintClientid = 0;
private int iintMonth = 0;
private int iintYear = 0;
private string istrFullName;
private DataSet idsInvoices;
private string dsReturnedData = "ClientInvoices";

// Constructor
public InvoiceList(int aintClientID, int aintMonthText, int aintYearText)
{
iintClientid = aintClientID;
iintMonth = aintMonthText;
iintYear = aintYearText;

// Connect to the PSSBilling_WebService.
PSSBilling.Service1 wsSearch = new PSSBilling.Service1();

// Define the dataset for this class.
idsInvoices = new DataSet();
idsInvoices = wsSearch.getInvoiceDataByClient( intClientid, iintMonth,
iintYear );

istrFullName =
Convert.ToString(idsInvoices.Tables["ClientInvoices"].Columns["full_name"].ColumnMapping["full_name"]);
Console.WriteLine(istrFullName);
}

[u]Here is my PROPERTY CODE</u>:

//Public Property created to EXPOSE the data elements for the INVOICE
FORM.

public string InvoiceFullName
{
get
{
return istrFullName; // THIS IS TELLING ME UNREACHABLE CODE
Console.WriteLine(istrFullName);
}
}
}
Reply With Quote
  #2 (permalink)  
Old February 4th, 2004, 06:14 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I can't see anything wrong with this. Can you post the exact error?
Reply With Quote
  #3 (permalink)  
Old February 4th, 2004, 06:27 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

As soon as return is found in a method (in this case, the Get accessor for the InvoiceFullName property), the return value is returned, and execution of the method stops:
Code:
get
{
  return istrFullName;
  // THIS IS TELLING ME UNREACHABLE CODE
  Console.WriteLine(istrFullName);
}
As you can see, the Console.WriteLine call occurs after the return statement and is therefore unreachable. Swap the two statements and you should be fine:
Code:
get
{
  Console.WriteLine(istrFullName);
  return istrFullName;
}
Not sure about the other problems you're having though. Can you elaborate a bit?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #4 (permalink)  
Old February 5th, 2004, 07:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Arlington, TX, USA.
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

In my class, I am trying to verify the VALUE in this field called "Full_Name" but I am getting back the FIELD NAME, "Full_Name" not the value in it. Should I not see the value with the parameters I have setup for this variable = (istrFullName =
Convert.ToString(idsInvoices.Tables["ClientInvoices"].Columns["full_name"].ColumnMapping["full_name"]);
?

In my PROPERTY I get nothing back in the Console.Writeline command.

Thank you guys for your time and help. If you can lend any more suggestions they would be appreciated.
Reply With Quote
  #5 (permalink)  
Old February 5th, 2004, 09:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Arlington, TX, USA.
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

A colleague of mine helped by stating that I had defined the ROW and that is why the value was not showing up. Here is what I did:

istrFullName = Convert.ToString(idsInvoices.Tables["ClientInvoices"].Rows[1]["full_name"]);

I did not realize I had to DEFINE the row that I was looking at.

Thank you guys again for your time and help. If you have any comments, suggestions or direction it would be appreciated.
Reply With Quote
  #6 (permalink)  
Old February 5th, 2004, 09:12 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

This code will return the name from the second row in the table in the dataset. The index are zero based, so Row[1] means the second row.

You can think of the Table in a DataSet like a normal table, or a spread sheet. It's divided in Rows and Columns:
Code:
DataTable myTable = idsInvoices.Tables["ClientInvoices"]

FullName = myTable.Rows[0]["FullName"].ToString() // returns FullName of first record
FullName = myTable.Rows[1]["FullName"].ToString() // returns FullName of second record
AnotherValue = myTable.Rows[0][0].ToString() // returns the first column for the first record
Take a look here: http://msdn.microsoft.com/library/de...gdatatable.asp and the articles around this one for more info.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #7 (permalink)  
Old February 6th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Arlington, TX, USA.
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for the help. It is appreciated.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question peterh Classic ASP Databases 3 January 17th, 2008 11:25 AM
Newbie question savoym JSP Basics 1 August 16th, 2006 03:15 AM
Newbie: XSLT & Scripts kwilliams XSLT 13 August 5th, 2005 11:39 AM
Newbie...probably a simple question...variables IP076 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 November 30th, 2004 02:24 PM
Newbie question maccer88 Access 1 October 18th, 2003 05:53 PM



All times are GMT -4. The time now is 07:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.