petercheung
petercheung

Reputation: 79

How can pass textBox value to another class

Can i press the textbox value to class file

Windows Form :

     private void button1_Click(object sender, EventArgs e)
        {

            string Staffid = Staffid_txt.Text;
            string Pwd = Pwd_txt.Text;
            dbConnect.UserAuthCommd();

dbConnect:

     public ConnectDB()
{
    Initialize();
}
.   
.
.
public void UserAuthCommd()

I don't know how can i get Staffid , Pwd into dbConnect and use staffid and pwd to SQL query

Upvotes: 0

Views: 146

Answers (1)

David
David

Reputation: 219087

If the UserAuthCommd method needs string values, then have it accept string values:

public void UserAuthCommd(string staffId, string password)
{
    //...
}

And pass it the values when you invoke it:

dbConnect.UserAuthCommd(Staffid_txt.Text, Pwd_txt.Text);

Upvotes: 2

Related Questions