[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Can't pass connection from one form to another

Posted on 2008-06-12
1
Medium Priority
?
223 Views
Last Modified: 2013-11-26
Hi everyone,

I'm completely stuck at passing the connection info from my login form to my main form. The program should:

- Connect to the remote MySQL DB
- Fetch a list of usernames so the user select his/her
- Validate the user's password with the MD5 password stored in the DB
- If the user and password matches, show the main form
- Open the main form having the connection stablished (this is the problem)

I attached two TXT files with both forms to see if anyone can help me with this.

Thanks a lot in advanced!!
login.txt
main.txt
0
Comment
Question by:Cesar Aracena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
Rurne earned 2000 total points
ID: 21771756
It looks like your MySQLConnection is simply falling out of scope.   In login.txt, you define

"Public Class frmLogin
    Dim conn As MySqlConnection
    Dim myCommand As New MySqlCommand
    Dim myAdapter As New MySqlDataAdapter"


conn, myCommand, and myAdapter are thus all local properties of the frmLogin class.  As you never pass it to frmMain before calling frmMain.Show(), calling conn.Open() and conn.Close() in frmMain_Load should result in error: frmMain.conn has no parameters, as it's a completely separate MySQLConnection from frmLogin.conn.

The easiest way around this would be to define conn, not as a property of either class, but as a global MySQLConnection, which you can then reference in the appropriate namespaces.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question