I'm using a DataSet to retrive data from a Database and access the values of the columsn returned. I then want to set the Text of various labels to the values of the columns. To do this I use to code below
after you fill the dataset you must declare a datarow dim dr as new datarow dr = dataset.tables(0).rows(0) and after that you use it like this: label1.text = dr("column_name1").ToString() label2.text = dr("column_name2").ToString() .... and here you are. HTH
Kiddu
wallaceoc
Member
360 Points
72 Posts
DataSet column values
Sep 06, 2004 01:55 PM|LINK
wallaceoc
Member
360 Points
72 Posts
Re: DataSet column values
Sep 07, 2004 07:05 AM|LINK
wallaceoc
Member
360 Points
72 Posts
Re: DataSet column values
Sep 07, 2004 08:30 AM|LINK
string strAppDetailsQry = "Select A.AppID, A.AppName, A.GripsID"; strAppDetailsQry += " from Application A, FAQ F"; strAppDetailsQry += " where F.AppID = A.AppID"; strAppDetailsQry += " AND F.FAQID = " + Int32.Parse(FAQID.Text); SqlCommand appDetailsCmd = new SqlCommand(strAppDetailsQry, conn); ... ... try { conn.Open(); dataAdapter = new SqlDataAdapter(strAppDetailsQry, conn); dsAppData = new DataSet(); dataAdapter.Fill(dsAppData); .... ... } ...This is really bugging me so please help! Regards, Wallacekiddu1
Member
30 Points
6 Posts
Re: DataSet column values
Sep 07, 2004 11:46 AM|LINK
wallaceoc
Member
360 Points
72 Posts
Re: DataSet column values
Sep 07, 2004 01:17 PM|LINK
mhatrerupesh
Member
18 Points
9 Posts
Re: DataSet column values
Dec 04, 2007 12:51 PM|LINK
How do i add logical table created (on the fly in the stored procedure, say @DisplayOutput) to DataAdapter ? plz help.........
THanks in advance
ThaDu
Member
2 Points
1 Post
Re: DataSet column values
Oct 07, 2008 08:55 AM|LINK
You can use as shown below[:D]:
txtRow0Col0.Text = dsAppData.Tables[0].Rows[0][0].ToString();
txtRow0Col1.Text = dsAppData.Tables[0].Rows[0][1].ToString();
txtRow1Col3.Text = dsAppData.Tables[0].Rows[1][3].ToString();
Susanta Kuma...
Member
364 Points
67 Posts
Re: DataSet column values
Mar 23, 2010 11:03 AM|LINK
txtFName.Text = Convert.ToString(ds.Tables[0].Rows[0]["FName"]);
lblLName.Text = Convert.ToString(ds.Tables[0].Rows[0]["LName"]);
Here "FName", "LName" are the Column Names, which u r getting from query like "Select stdFName AS Fname, stdLName AS LName From Student".
Use Convert.Tostring() because it can handle null exception.
---------------------
Susanta Kumar Rath
Sr. Software Engineer
First American(India) Pvt. Ltd.
Bangalore, India