Page view counter

DataSet column values

Last post 10-07-2008 4:55 AM by ThaDu. 6 replies.

Sort Posts:

  • DataSet column values

    09-06-2004, 9:55 AM
    • Loading...
    • wallaceoc
    • Joined on 08-23-2004, 6:06 AM
    • Posts 72
    • Points 360
    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


    appID.Text = dsAppData.Tables[0].Columns[0].ToString();
    appName.Text = dsAppData.Tables[0].Columns[1].ToString();
    gripsID.Text = dsAppData.Tables[0].Columns[2].ToString();


    The problem is that it sets the text of the labels to the column names and not the values. Am I using the wrong code?

    Thanks,

    Wallace
  • Re: DataSet column values

    09-07-2004, 3:05 AM
    • Loading...
    • wallaceoc
    • Joined on 08-23-2004, 6:06 AM
    • Posts 72
    • Points 360
    Sorry but does anybody have any idea on this one?

    Thanks,

    Wallace
  • Re: DataSet column values

    09-07-2004, 4:30 AM
    • Loading...
    • wallaceoc
    • Joined on 08-23-2004, 6:06 AM
    • Posts 72
    • Points 360
    Another point that might help is when I try to write the name of the table as follows:


    Response.Write(dsAppData.Tables[0].TableName.ToString());


    The word "Table" is outputted on the screen. Anbody have any ideas?

    The code I use to fill the DataSet is as follows:


    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,

    Wallace
  • Re: DataSet column values

    09-07-2004, 7:46 AM
    • Loading...
    • kiddu1
    • Joined on 07-10-2003, 4:40 AM
    • Posts 6
    • Points 30
    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
  • Re: DataSet column values

    09-07-2004, 9:17 AM
    • Loading...
    • wallaceoc
    • Joined on 08-23-2004, 6:06 AM
    • Posts 72
    • Points 360
    Legend!!
  • Re: DataSet column values

    12-04-2007, 8:51 AM
    • Loading...
    • mhatrerupesh
    • Joined on 09-29-2007, 12:01 PM
    • Mumbai
    • Posts 9
    • Points 18

    How do i add logical table created (on the fly in the stored procedure, say @DisplayOutput)  to DataAdapter ? plz help.........

    THanks in advance

  • Re: DataSet column values

    10-07-2008, 4:55 AM
    • Loading...
    • ThaDu
    • Joined on 10-07-2008, 4:48 AM
    • Posts 1
    • Points 2

    You can use as shown belowBig Smile:

    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(); 

Page 1 of 1 (7 items)