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. Adding text box input to a dataset table

Adding text box input to a dataset table

Scheduled Pinned Locked Moved C#
question
6 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.
  • M Offline
    M Offline
    mprice214
    wrote on last edited by
    #1

    Hi all, I have two forms. On one form is a text box and the other form hold a data table that is the source of a dataset. Upon entering text in the first form and clicking a button, I want to have the text added to the dataset data table. I have unsuccessfully tried instantiating the data table using DataRow newRow...... as the textbox form doesn't allow me to "see" the data table or the dataset. Can someone point me in the right direction here? Thanks.

    D 1 Reply Last reply
    0
    • M mprice214

      Hi all, I have two forms. On one form is a text box and the other form hold a data table that is the source of a dataset. Upon entering text in the first form and clicking a button, I want to have the text added to the dataset data table. I have unsuccessfully tried instantiating the data table using DataRow newRow...... as the textbox form doesn't allow me to "see" the data table or the dataset. Can someone point me in the right direction here? Thanks.

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #2

      I'm not sure I follow exactly what you are trying to do, but if your data entry form is accessible from the data table form, just make the input text public and read it from the data table form. If that's not what you need, then perhaps you could explaining your dilemma a little better and let us know what you've tried so far.

      CQ de W5ALT

      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

      M 1 Reply Last reply
      0
      • D Dr Walt Fair PE

        I'm not sure I follow exactly what you are trying to do, but if your data entry form is accessible from the data table form, just make the input text public and read it from the data table form. If that's not what you need, then perhaps you could explaining your dilemma a little better and let us know what you've tried so far.

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        M Offline
        M Offline
        mprice214
        wrote on last edited by
        #3

        Let me simplify things a bit to be more clear. Let's say I have two forms. There is a textbox on Form1 and I'll just have some default text that resides in the textbox. On Form1_Load shown below, frmCalData is instantiated and shown. frmCaldata has a dataset dsCalData with a data table tblCalData.

        private void Form1_Load(object sender, EventArgs e)
        frmCalData frmCal = new frmCalData();
        frmCal.Show();

        I believe I should be eventually calling out something like this:

        DataRow row = tblCalData.NewRow();
        tblCalData.Rows.Add(textbox1.Text);

        However, in the Form1_Load method, I cannot call out tblCalData. As this is new to me, I am shooting somewhat blind, so any guidance will be greatly appreciated.

        D 1 Reply Last reply
        0
        • M mprice214

          Let me simplify things a bit to be more clear. Let's say I have two forms. There is a textbox on Form1 and I'll just have some default text that resides in the textbox. On Form1_Load shown below, frmCalData is instantiated and shown. frmCaldata has a dataset dsCalData with a data table tblCalData.

          private void Form1_Load(object sender, EventArgs e)
          frmCalData frmCal = new frmCalData();
          frmCal.Show();

          I believe I should be eventually calling out something like this:

          DataRow row = tblCalData.NewRow();
          tblCalData.Rows.Add(textbox1.Text);

          However, in the Form1_Load method, I cannot call out tblCalData. As this is new to me, I am shooting somewhat blind, so any guidance will be greatly appreciated.

          D Offline
          D Offline
          Dr Walt Fair PE
          wrote on last edited by
          #4

          When you try to access tblCalData from Form1, what happens? If it gives you an error, what error is shown? You should be able to access tblCalData from Form1 as frmCal.tblCalData, but it will need to be set public for it to be accessible. On the other hand, is there a reason that you need both in 2 separate forms?

          CQ de W5ALT

          Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

          M 1 Reply Last reply
          0
          • D Dr Walt Fair PE

            When you try to access tblCalData from Form1, what happens? If it gives you an error, what error is shown? You should be able to access tblCalData from Form1 as frmCal.tblCalData, but it will need to be set public for it to be accessible. On the other hand, is there a reason that you need both in 2 separate forms?

            CQ de W5ALT

            Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

            M Offline
            M Offline
            mprice214
            wrote on last edited by
            #5

            DataRow row = frmCal.dataTable1.NewRow (label4.Text,"0","0");
            frmCal.dataTable1.Rows.Add(row);

            The error is that 'NewRow' Takes '3' arguments. However, there are three columns and the NewRow method indicates that it will create the same schema as the table so I thought I'd have to have place markers for the other two columns. I have a separate form for just the data table from the main user interface form. Updated: Just changed the above to:

            DataRow row = frmCal.dataTable1.NewRow();
            row[0] = label4.Text;
            frmCal.dataTable1.Rows.Add(row);

            That works fine. Thanks for keeping me scratching my head :)

            modified on Wednesday, May 5, 2010 10:07 PM

            D 1 Reply Last reply
            0
            • M mprice214

              DataRow row = frmCal.dataTable1.NewRow (label4.Text,"0","0");
              frmCal.dataTable1.Rows.Add(row);

              The error is that 'NewRow' Takes '3' arguments. However, there are three columns and the NewRow method indicates that it will create the same schema as the table so I thought I'd have to have place markers for the other two columns. I have a separate form for just the data table from the main user interface form. Updated: Just changed the above to:

              DataRow row = frmCal.dataTable1.NewRow();
              row[0] = label4.Text;
              frmCal.dataTable1.Rows.Add(row);

              That works fine. Thanks for keeping me scratching my head :)

              modified on Wednesday, May 5, 2010 10:07 PM

              D Offline
              D Offline
              Dr Walt Fair PE
              wrote on last edited by
              #6

              I know how it goes - sometimes it can be frustrating figuring things out, but it feels so nice when it finally works. :-D Glad to hear you got it working!

              CQ de W5ALT

              Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

              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