title: Getting the value of the label from other form using vb.net
body: <p>It is not working, the labels only goes back into its default values. What do you think is the problem?</p>
  
  <p>Okay this is my code:</p>
  
  <p>Actually I'm using mysql as my database here</p>
  
  <p>This is the form that generates the values of the labels:</p>
  
  <pre><code>Private Sub ProfileControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Try
          Dim conn As New MySqlConnection(ServerString)
          Dim dap As New MySqlDataAdapter("select * from employee where LogInID = '" &amp; Main.ID.Text &amp; "'", conn)
          Dim dt As New DataTable
          dap.Fill(dt)
  
          employeenum = dt.Rows(0).Item("EmployeeID")
          position = dt.Rows(0).Item("Position")
          employeename = dt.Rows(0).Item("FirstName") + " " + dt.Rows(0).Item("LastName")
  
          lblemployeename.Text = employeename
          lblemployeenum.Text = employeenum
          EmpPosition.Text = position
  
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  </code></pre>
  
  <p>And this is the form that will retrieve the values of the 3 labels.</p>
  
  <pre><code>Private Sub addsavebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addsavebutton.Click
      Dim profile As New ProfileControl
  
  
      If txtbranchname.Text &lt;&gt; "" Then
          If addsavebutton.Text = "ADD" Then
  
              Dim zero As Integer = 0
              Dim SQLStatement As String = "INSERT INTO branch(BranchName,Centers)VALUES('" &amp; txtbranchname.Text &amp; "','0') "
              SaveCenter(SQLStatement)
              logdate = Convert.ToDateTime(Date.Now).ToString("yyyy-MM-dd hh:mm:ss")
              logdate2 = Format(Date.Now, "yyyy-MM-dd")
              status = "Added Branch " + txtbranchname.Text
              SQLStatement = "INSERT INTO log(EmployeeID,Name,EmployeePosition,Date,DateTime,Status)VALUES('" &amp; profile.lblemployeenum.Text &amp; "','" &amp; profile.lblemployeename.Text &amp; "','" &amp; profile.EmpPosition.Text &amp; "','" &amp; logdate2 &amp; "','" &amp; logdate &amp; "','" &amp; status &amp; "' )"
              Savelog(SQLStatement)
              txtbranchname.Clear()
          ElseIf addsavebutton.Text = "SAVE" Then
              Dim Query As String
  
              Dim con As MySqlConnection = New MySqlConnection(ServerString)
              con.Open()
  
              Query = "UPDATE branch SET  BranchName = '" &amp; txtbranchname.Text &amp; "' WHERE BranchCode = '" &amp; txtbranchcode.Text &amp; "'"
  
  
              Dim cmd As MySqlCommand = New MySqlCommand(Query, con)
              Dim i As Integer = cmd.ExecuteNonQuery()
              If (i &gt; 0) Then
  
                  'success
                  Dim Successtext As New MsgSuccess
                  Successtext.PassedText = "Record is Successfully Updated"
                  Successtext.ShowDialog()
  
  
                  Dim SQLStatement As String
                  logdate = Convert.ToDateTime(Date.Now).ToString("yyyy-MM-dd hh:mm:ss")
                  logdate2 = Format(Date.Now, "yyyy-MM-dd")
                  status = "Updated Branch: " + txtbranchcode.Text + ", " + txtbranchname.Text
                  SQLStatement = "INSERT INTO log(EmployeeID,Name,EmployeePosition,Date,DateTime,Status)VALUES('" &amp; profile.lblemployeenum.Text &amp; "','" &amp; profile.lblemployeename.Text &amp; "','" &amp; Main.lbldate.Text &amp; "','" &amp; logdate2 &amp; "','" &amp; logdate &amp; "','" &amp; status &amp; "' )"
                  Savelog(SQLStatement)
  
                  srchTextBox.Clear()
                  con.Close()
  
              Else
                  'error
                  Dim Errortext As New Msgerror
                  Errortext.PassedText = "Record is not Updated"
                  Errortext.ShowDialog()
  
  
  
              End If
  
  
          End If
      Else
          Dim Errortext As New Msgerror
          Errortext.PassedText = "All Entries with * must be filled"
          Errortext.ShowDialog()
  
      End If
  End Sub
  </code></pre>