Another Question

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Another Question

 
0
  #1
Oct 20th, 2008
ok, I'm asking another question now....

Previously I had code to add the requester and asignee emails, if the are both empty then I need to build the list. Here is my code:

  1. private string BuildUserList(int p_intSendToRoleID)
  2. {
  3.    
  4.     DataSet dstUsers = new DataSet();
  5.     DataRow drwData = default(DataRow);
  6.     string strUserList = null;
  7.    
  8.     try
  9. {
  10.         dstUsers = User.GetUsersByRole(p_intSendToRoleID);
  11.        
  12.         foreach ( drwData in dstUsers.Tables(0).Rows)
  13. {
  14.             strUserList += (string)(Information.IsDBNull(drwData("Email")) ? "" : Convert.ToString(drwData("Email")) + ";");
  15.         }
  16.        
  17.         return strUserList;
  18.     }
  19.    
  20.     catch (Exception ex)
  21. {
  22.         throw;
  23.     }
  24.    
  25. }

private string BuildUserList(int p_intSendToRoleID) gives me an error at string and
DataSet dstUsers = new DataSet(); gives me an error at DataSet()
both errors are:"Expected class, delegate, enum, interface, or struct"

and I get "Type or namespace definition, or end-of-file expected" at the last bracket.

I'm stuck again - can anyone help me understand?
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,614
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 131
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: Another Question

 
0
  #2
Oct 20th, 2008
Is that your entire code file? You don't seem to have neither a namespace nor a class defined, both of which are needed.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,024
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 300
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic

Re: Another Question

 
0
  #3
Oct 20th, 2008
aaargh
Last edited by ddanbe; Oct 20th, 2008 at 4:00 pm. Reason: I was wrong
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: Another Question

 
0
  #4
Oct 20th, 2008
scru - I sent you the entire class in pm I don't normally do that but explain why in the message. . .

ddanbe,


it's probably me - I've used VB.Net at work but we are switching to C# and I have to get better at the differences.

In VB.Net I had

  1. Private Function BuildUserList(ByVal p_intSendToRoleID As Integer) As String
  2.  
  3. Dim dstUsers As New DataSet
  4. Dim drwData As DataRow
  5. Dim strUserList As String
  6.  
  7. Try
  8. dstUsers = User.GetUsersByRole(p_intSendToRoleID)
  9.  
  10. For Each drwData In dstUsers.Tables(0).Rows
  11. strUserList &= CStr(IIf(IsDBNull(drwData("Email")), "", Convert.ToString(drwData("Email")) & ";"))
  12. Next
  13.  
  14. Return strUserList
  15.  
  16. Catch ex As Exception
  17. Throw
  18. End Try
  19.  
  20. End Function

it filled the dataset when calling the User class . . .

will C# not fill it with:
dstUsers = User.GetUsersByRole(p_intSendToRoleID);
Last edited by rapture; Oct 20th, 2008 at 4:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,024
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 300
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic

Re: Another Question

 
0
  #5
Oct 20th, 2008
In the above post I obviously had some trouble on my own.
Look at this website
http://www.ironspeed.com/Designer/5....terface_or.htm
It might help.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,846
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 753
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Another Question

 
2
  #6
Oct 20th, 2008
>You don't seem to have neither a namespace nor a class defined, both of which are needed.
A namespace isn't required, but for obvious reasons at least one class is.
New members chased away this month: 4
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: Another Question

 
0
  #7
Oct 20th, 2008
Thanks guys,

I had them both declared - I had the brackets misaligned . . . hard to get used to those things after not using them in VB.Net . . .
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC