praveenuni
asked on
Read values from DataSet
Hello,
I'm getting the dataset from another asp.net into my current page. I want to read the total number of tables (into string), table names (into arraylist). and How can read any value from any table in the dataset. For eg., if I want to read 2nd value in 2nd column in 3rd table of dataset, how can I do that?
Thanks
Praveen
I'm getting the dataset from another asp.net into my current page. I want to read the total number of tables (into string), table names (into arraylist). and How can read any value from any table in the dataset. For eg., if I want to read 2nd value in 2nd column in 3rd table of dataset, how can I do that?
Thanks
Praveen
ASKER
what does Tables[2].Rows[2][3] means? Is it the second value in 3rd column in table 2?
Thanks
Praveen
Thanks
Praveen
Indexes in C# start with 0. So this means the 3rd row value of the 4th column in the 3rd table.
ASKER
I tried this Tables[0].Rows[0][0] - to get the 1st row value of 1st column in 1st table. But the system is throwing an error saying " There is no row at position1".
But in my database I have 3 tables each with 2 records and 2 columns. Whys is that happening?
Thanks
Praveen
But in my database I have 3 tables each with 2 records and 2 columns. Whys is that happening?
Thanks
Praveen
How did you load the database tables into your dataset? Are you sure it was properly loaded?
ASKER
This is my first time loading the database tables into dataset. I created the dataset following the walk through in one of the websites. This is how I did it
(Created ODBC Connection ... dragged and dropped the tables into the form (it created 3 data adapters for 3 tables) .. selected one data adapter and created dataset with all the tables ) .. Is there anything wrong I did ?
(Created ODBC Connection ... dragged and dropped the tables into the form (it created 3 data adapters for 3 tables) .. selected one data adapter and created dataset with all the tables ) .. Is there anything wrong I did ?
ASKER
I tried to enter values into the dataset manually like this :
this.GBResults.Tables.Add( "Table1");
this.GBResults.Tables["Tab le1"].Colu mns.Add("F ield");
this.GBResults.Tables["Tab le1"].Colu mns.Add("I D");
this.GBResults.Tables["Tab le1"].Rows [0][0] = 1;
this.GBResults.Tables["Tab le1"].Rows [0][1] = 2;
this.GBResults.Tables["Tab le1"].Rows [1][0] = 3;
this.GBResults.Tables["Tab le1"].Rows [1][1] = 4;
But the system is throwing the same "There is row at position 0" error.
Why is this happening?
Thanks
Praveen
this.GBResults.Tables.Add(
this.GBResults.Tables["Tab
this.GBResults.Tables["Tab
this.GBResults.Tables["Tab
this.GBResults.Tables["Tab
this.GBResults.Tables["Tab
this.GBResults.Tables["Tab
But the system is throwing the same "There is row at position 0" error.
Why is this happening?
Thanks
Praveen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Table Names Into ArrayList:
string[] tableNames = new string[dataSet.Tables.Coun
for (int i = 0; i < dataSet.Tables.Count; i++)
tableNames[i] = dataSet.Tables[i].TableNam
To read any Value in Table in DataSet
dataSet.Tables[2].Rows[1][