简体   繁体   中英

Get data from database, and show it in a TextBox on another form

Just so you are all aware, I have almost solved the issue BUT there is a key item in my way.

Alright. I have a "DataModule" class where there are several DataAdaptors, my DataSet, and the Connection.

My database is working fine, and so is saving and retrieving (including updating and deleting) data. If I put a TextBox on the DataModule form, and use an OleDbReader, and the following statement: txtBoxTest.Text = reader["firstName"].ToString();

Then the selected record's (which I have chosen by ID number) first name appears in the box.

However, the ACTUAL place for this data to appear is on another form, and as we know, components on a Windows Forms Application are set to "private", by default. Thus, my dilemma.

Question is below this line

How can I make the data appear in the correct form's TextBoxes (which is PatientRecord.cs) using the DataModule class' reader, and the statement of code I provided?

Many thanks!

There are Some way for Data transfer between forms.I explain one of common ways:

Sender form:

 FrmChild child = new FrmChild(number,line,this.Width);
            child.Owner = this;

            child.Show();

Receiver form:

public partial class FrmChild : Form
    {

        int frmw;//A public varaible

        public FrmChild()//normal constrauctor
        {
            InitializeComponent();

        } 

        public FrmChild(String cNumber,byte LINE,int w)//custom constrauctor
        {

            frmw = w;
            InitializeComponent();
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM