Home All Groups Group Topic Archive Search About

problem reading data from dataTable..

Author
18 Aug 2006 9:45 PM
Marko Vuksanovic
I am using the following code, and would like to check what is stored in each dataTable (dt) row and column,.. unfortunatelly I cannot figure out a way to do so...  How can i get a value from specific row and column? for example row0, and column0...

dt.Columns.Add("id");
dt.Columns.Add("owner");
dt.Columns.Add("secret");
dt.Columns.Add("server");
dt.Columns.Add("title");
dt.Columns.Add("ispublic");
dt.Columns.Add("isfriend");
dt.Columns.Add("isfamily");

for (int i = 0; i < temp.GetElementsByTagName("photo").Count; i++)
{
for (int j = 0; j < temp.GetElementsByTagName("photo")[i].Attributes.Count; j++)
{
dr = dt.NewRow();
dr[j]=temp.GetElementsByTagName("photo")[i].Attributes[j].Value;
}
dt.Rows.Add(dr);
System.Windows.MessageBox.Show(dt.Columns[i].ToString());
}

Thanks, M.V.

Author
18 Aug 2006 11:13 PM
Michael
for (int i = 0; i < ds.Tables.Count; i++)
            {
                for (int j = 0; j < ds.Tables[i].Rows.Count; j++)
       {
                    Console.WriteLine("Table: {0}, Row: {1}:",
ds.Tables[i].TableName, j);
                    for (int k = 0; k < ds.Tables[i].Columns.Count; k++)
                    {
                        Console.WriteLine("Table: {0}, Column: {1}, Value:
{2}", ds.Tables[i].TableName, ds.Tables[i].Columns[j].ColumnName,
ds.Tables[i].Rows[j][k]);
                    }
                    //Console.WriteLine("Table: {0}, Column: {1}, Value:
{2}", ds.Tables[i].TableName, ds.Tables[i].Columns[j].ColumnName,
ds.Tables[i].);

                }

            }

Sorry it's a little messy in the post. Visual Studio will clean it up for
you.

Mike
http://www.seeknsnatch.com
-------------------------------------

"Marko Vuksanovic" <markovuksano***@hotmail.com> wrote in message
news:C4695308-6E46-4B9E-81C7-C01021F4869E@microsoft.com...
I am using the following code, and would like to check what is stored in
each dataTable (dt) row and column,.. unfortunatelly I cannot figure out a
way to do so...  How can i get a value from specific row and column? for
example row0, and column0...
dt.Columns.Add("id");
dt.Columns.Add("owner");
dt.Columns.Add("secret");
dt.Columns.Add("server");
dt.Columns.Add("title");
dt.Columns.Add("ispublic");
dt.Columns.Add("isfriend");
dt.Columns.Add("isfamily");
for (int i = 0; i < temp.GetElementsByTagName("photo").Count; i++)
{
for (int j = 0; j < temp.GetElementsByTagName("photo")[i].Attributes.Count;
j++)
{
dr = dt.NewRow();
dr[j]=temp.GetElementsByTagName("photo")[i].Attributes[j].Value;
}
dt.Rows.Add(dr);
System.Windows.MessageBox.Show(dt.Columns[i].ToString());
}
Thanks, M.V.

AddThis Social Bookmark Button