I Have 2 form,what i'm trying to do is get a value from a TextBox on form1 then assign it into other variable in form2 so i could re-use it in form2 without re-calling it from form1
Form1 (It's a login form)
public void LoginBttn_Click(object sender, EventArgs e)
    {
        cnnctString = "SERVER=" + server + ";" + "DATABASE=" + DB + ";" + "UID=" + uid + ";" + "PASSWORD=" + pwd + ";";
        connection = new MySqlConnection(cnnctString); //The one that i want to fetch for the 2nd form
        if (OpenConnection() == true)
        {
            Form2 menu = new Form2();
            menu.Visible = true;
            this.Visible = false;
        }
    }
In the form1 i have initialize server, DB, UID, and pwd (each of them have value, pwd and UID value are fetched from Textbox ) and the OpenConnection also return true.
and then on
Form2
public Form1 oF;
public MySqlConnection NTD()
    {
        MySqlConnection F = oF.connection;//It's Highlighted in this line.
        return F;
    }
public MySqlCommand cmd = new MySqlCommand();
public void A9_Click(object sender, EventArgs e)
    {
         A9.Text = "X";
         string query = "UPDATE orders SET Client=" + Name + " , Stat='1' WHERE No='A9'";
         cmd.CommandText = query;
         cmd.Connection = NTD();
         cmd.ExecuteNonQuery();
    }
name value is fetched from a Textbox on the same form
There's no compile error and other before-compile error
But When i succesfully run it and click button A9 it's throw NullReferenceException
I'm not sure that connection is null since i can sucessfully login and show the form2.
Am i miss something ? any idea about this ?
I'm a novice and don't know what wrong.And if you could,please describe it as easy as possibble if it's require something advance.
Thankyou.
 
    