?
Solved

C# Database Row

Posted on 2012-03-09
4
Medium Priority
?
321 Views
Last Modified: 2012-03-12
Can anyone please explain me what does the myRow in ds.Tables["wc"] does in this code. For now I don't care if compiles or not. I just need to understand the its functionality.

foreach (DataRow myRow in ds.Tables["wc"].Rows)
	{

		if (myRow[4].ToString() == string.Empty)
		{

			sr.WriteLine(string.Concat(new object[] { 
				"'", myRow[0], "','", myRow[1], "','", myRow[2], "',", string.Empty, ",'", myRow[4], "','", myRow[5], "',", string.Empty, ",'", myRow[7], 
				"',", myRow[8], ",'", myRow[9], "'"
						//}
							}));

Open in new window

0
Comment
Question by:pauledwardian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 2000 total points
ID: 37703935
myRow is an iterator variable for the foreach loop. It represents each DataRow (it's corresponding type) found within the DataTable it is iterating over. In this case, the DataTable is housed within a DataSet. This DataSet is pointed to by the variable ds. Within the DataSet's Tables collection, you are getting to the "wc" table by indexing that property using the string "wc". (The square brackets represent C#'s index operator.) The table that is returned by that indexing operation has its Rows property iterated over using the aforementioned iterator variable.
0
 

Author Comment

by:pauledwardian
ID: 37705592
So WC is the table name?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 37706165
As it exists within the DataSet, yes. It could have been loaded from any number of database tables with arbitrary names, or it could have been loaded from a file, or entered by the user, etc. But with respect to the DataSet, the DataTable was given the name "wc".
0
 

Author Closing Comment

by:pauledwardian
ID: 37712199
Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question