problem reading data from dataTable..

M

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").Attributes.Count; j++)
{
dr = dt.NewRow();
dr[j]=temp.GetElementsByTagName("photo").Attributes[j].Value;
}
dt.Rows.Add(dr);
System.Windows.MessageBox.Show(dt.Columns.ToString());
}

Thanks, M.V.
 
M

Michael

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

}

}

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

Mike
http://www.seeknsnatch.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").Attributes.Count;
j++)
{
dr = dt.NewRow();
dr[j]=temp.GetElementsByTagName("photo").Attributes[j].Value;
}
dt.Rows.Add(dr);
System.Windows.MessageBox.Show(dt.Columns.ToString());
}
Thanks, M.V.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top