how to retrieve value stored in dataset?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krunal kakadia
    New Member
    • Feb 2011
    • 1

    how to retrieve value stored in dataset?

    hi all,

    i have image path name in database and i am fetching it this way.
    Code:
    con.Open();
    string img= "select imgPath from Tbl_Image where imgId='1'";
    SqlCommand cmd = new SqlCommand(img,con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    con.Close();
    i got path name in ds.

    now my question is how to assign that path to my image.

    //imgCurrent.Imag eUrl

    Thanks you,
    krunalkakadia
    Last edited by Frinavale; Feb 28 '11, 07:58 PM. Reason: Please post code in code tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Your DataSet contains a set of DataTables that contain the data that you requested from the database. In your case it looks like the result of your query is 1 table with 1 record/row in it.

    You need to use the DataSet.Tables Property to retrieve the table. Then you need to retrieve the item you are interested in from the row/column in the table.

    -Frinny

    Comment

    • dip_developer
      Recognized Expert Contributor
      • Aug 2006
      • 648

      #3
      imgCurrent.Imag eUrl=ds.Tables( 0).Rows(0).Item ("imgPath")

      Comment

      Working...