Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get data to textfield from dataset

get data to textfield from dataset

Scheduled Pinned Locked Moved C#
questioncssdatabase
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simsen
    wrote on last edited by
    #1

    I know it's a stupid newbee question, but I have looked everywhere and can't find the answer.... I know how I get data from a dataset to a datagridview but how do I get data from a dataset to a textfield? My code: private void loadFakturaVis() { try { //create a connection string to the access database OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=;Password=; Data Source=" + myDB); // Create the DataSet ds = new DataSet("FakturaOrdre"); // Fill the Dataset with Kunder, map Default Tablename // "Table" to "Kunder". da = new OleDbDataAdapter("SELECT Kunder.KundeId, Kunder.Navn,Faktura.FakturaID, Faktura.KundeID, Ordre.OrdreID, Ordre.FakturaNr, Ordre.Antal, Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER JOIN ((Kunder INNER JOIN Faktura ON Kunder.KundeId = Faktura.KundeID) INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn); da.SelectCommand.Parameters.Add("@fakid", OleDbType.Integer); da.SelectCommand.Parameters["@fakid"].Value = fakid; da.TableMappings.Add("Table", "Ordre"); da.Fill(ds); // The DataViewManager returned by the DefaultViewManager // property allows you to create custom settings for each // DataTable in the DataSet. dsView = ds.DefaultViewManager; // Databinding for the Grid's dgrOrdre.DataSource = dsView; dgrOrdre.DataMember = "Ordre"; } catch (Exception ex) { MessageBox.Show("Exception" + ex); } } Now I want to do following: Nu vil jeg så gerne lave følgende i min kode: //Databinding for the fields txtNavn.Text = ???????? Now I want to get the FakturaID from the dataset and put into the the textfield txtNavn.Text - but I don't know what I shal put in the place of my questions. Kind regards, simsen :-)

    R 1 Reply Last reply
    0
    • S simsen

      I know it's a stupid newbee question, but I have looked everywhere and can't find the answer.... I know how I get data from a dataset to a datagridview but how do I get data from a dataset to a textfield? My code: private void loadFakturaVis() { try { //create a connection string to the access database OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=;Password=; Data Source=" + myDB); // Create the DataSet ds = new DataSet("FakturaOrdre"); // Fill the Dataset with Kunder, map Default Tablename // "Table" to "Kunder". da = new OleDbDataAdapter("SELECT Kunder.KundeId, Kunder.Navn,Faktura.FakturaID, Faktura.KundeID, Ordre.OrdreID, Ordre.FakturaNr, Ordre.Antal, Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER JOIN ((Kunder INNER JOIN Faktura ON Kunder.KundeId = Faktura.KundeID) INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn); da.SelectCommand.Parameters.Add("@fakid", OleDbType.Integer); da.SelectCommand.Parameters["@fakid"].Value = fakid; da.TableMappings.Add("Table", "Ordre"); da.Fill(ds); // The DataViewManager returned by the DefaultViewManager // property allows you to create custom settings for each // DataTable in the DataSet. dsView = ds.DefaultViewManager; // Databinding for the Grid's dgrOrdre.DataSource = dsView; dgrOrdre.DataMember = "Ordre"; } catch (Exception ex) { MessageBox.Show("Exception" + ex); } } Now I want to do following: Nu vil jeg så gerne lave følgende i min kode: //Databinding for the fields txtNavn.Text = ???????? Now I want to get the FakturaID from the dataset and put into the the textfield txtNavn.Text - but I don't know what I shal put in the place of my questions. Kind regards, simsen :-)

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      try txtNavn.Text = ds.Tables[0].Rows[0]["FakturaID"].ToString();

      rahul

      S 1 Reply Last reply
      0
      • R rah_sin

        try txtNavn.Text = ds.Tables[0].Rows[0]["FakturaID"].ToString();

        rahul

        S Offline
        S Offline
        simsen
        wrote on last edited by
        #3

        Thank you very much. That was exactly what I needed Kind regards, simsen :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups