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