title: Using MySQL to Create a Login page in Visual Studio 2010
body: <p>I am using Visual Studio 2010. I can connect to my MySQL datababse no problem by clicking my login button.</p>
  
  <p>Now I can't figure out how to query the database and check if username and password are correct, and switch to a different form, to display the data loaded from the database.</p>
  
  <p>Can Anyone Help?? Please</p>
  
  <p>I should have posted my Code</p>
  
  <p>This is Login.vb Form</p>
  
  <pre><code>Imports MySql.Data.MySqlClient
  
  Public Class Login
      Dim conn As MySqlConnection
  
      Private Sub Login_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Login_btn.Click
          conn = New MySqlConnection
          conn.ConnectionString = "server=localhost;user id=root;password=johnny;database=test"
  
          Try
              conn.Open()
              If conn.State = ConnectionState.Open Then
                  connectionstatus.Text = "Connected to Database"
                  conn.Close()
              End If
          Catch myerror As MySqlException
              connectionstatus.Text = "Unable to Connect to Database"
          Finally
              conn.Dispose()
  
          End Try
      End Sub
  End Class
  </code></pre>
  
  <p>When the login is completed, and username and password are correct, I want it to load Main.vb.</p>