get data to textfield from dataset
-
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 :-)
-
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 :-)