Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset/Datatable problem

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
US
Hi.

I am trying to read a column from a datatable and cant seem to get the syntax correct

Basic desire is to use a dataset to read an xml file then pick a row from the first datatable, but everytime I try it tells me I am using the datatable as a method...

Hopefully it is obvious as I cant find it. (I am a bit of a c# newbie)

code:
Code:
        System.Data.DataSet ds = new System.Data.DataSet();

        ds.ReadXmlSchema(Server.MapPath("") + "/quotes.xls");
        ds.ReadXml(Server.MapPath("") + "/quotes.xml");
       
        foreach (System.Data.DataTable dt in ds.Tables)
        {
            if (dt.TableName == "Table1") 
            { 
                int i = dt.Rows.Count;
                Random r = new Random();
                i = r.Next(0, i + 1);
                divTestimonials.InnerHtml = dt.Rows(i)(0);
                [green]//the above row throws an error[/green]
            }
        }
      }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top