CryoEnix Posted February 24, 2007 Posted February 24, 2007 Hi there guys, I've managed to populate a dataset with a table (from a SQL query), and I'm trying to access the data in it directly instead of binding it to a dataGrid. How would I go about this? Say I had the following Table: ID Name Password 1 Bob BobsPassword 2 Colin ColinsPassword I want something like: dataG.Column["name"].Row[0] to equal "bob" dataG.Column["id"].Row[1] to equal "2" I can't seem to navigate my way through the web of properties myself - please help! Quote Chaos is merely logic beyond human comprehension
CryoEnix Posted February 24, 2007 Author Posted February 24, 2007 Never mind peeps, after perusing the net some more I've found the solution. I need to create DataRows to handle the data, row at a time. Thanks anyway! Quote Chaos is merely logic beyond human comprehension
FZelle Posted February 25, 2007 Posted February 25, 2007 No you don't neet to create DataRows. dataG.Rows[0]["Name"] has the value of the "Name" column in the first datarow Quote
CryoEnix Posted February 25, 2007 Author Posted February 25, 2007 FZelle - cheers for the code. It didn't work, but after a bit off playing with it it was fine like this: dataG.Tables[0].Rows[0]["Name"] The Tables[0] part was omitted - do you know what the Tables index actually refers to? I'd imagine there should only be two dimensions for a table... Quote Chaos is merely logic beyond human comprehension
amir100 Posted February 26, 2007 Posted February 26, 2007 Every dataset has a collection of datatable. So the index in the Tables[0] refer to the first table filled in the dataset. If I remember correctly, you could also access it using Tables["yourtablename"]. This way is easier to be certain which datatable you're accessing. Try reading MSDN for the structure of DataSet. You'll find enough reference to get you started. Quote Amir Syafrudin
CryoEnix Posted February 26, 2007 Author Posted February 26, 2007 Once again, you guys have proved that your .NET (ninja) skills know no bounds. Cheers again, I appreciate the help! Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.