简体   繁体   中英

how to display data from database in another form label

I'm trying to get data from database and put it in a label in a different form(student profile)

http://s30.postimg.org/w5ruf5jkh/database_post_error.png ( http://s30.postimg.org/w5ruf5jkh/database_post_error.png )

I have exposed the label from the student profile form:

public string Label9 {
            get
            {
                return this.label9.Text;
            }

            set 
            {
                this.label9.Text = value;            
            }
        }

but the problem is this:

An object reference is required for the non-static field, method, or property 'Student_Profile.Label9.get'

so i have to create a new instance of an object or set it to static? how would i do that?

You are trying to set it to the class (Student_Profile).

You need to set it to your object which begins with small "s" ( studentprofile ).

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