簡體   English   中英

如何將textBox值傳遞給另一個類

[英]How can pass textBox value to another class

我可以按文本框值輸入類文件嗎

Windows表格:

     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()

我不知道如何獲取Staffid,Pwd到dbConnect以及如何使用staffid和pwd進行SQL查詢

如果UserAuthCommd方法需要字符串值,則使其接受字符串值:

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

並在調用它時傳遞值:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM