frank Lu

frank Lu

  • NA
  • 6
  • 465

C# Windows Form using Oracle connection how to keep it.

Aug 2 2018 10:10 AM

I have a windows form to allow user to authenticate their credentials in a "Sign in Screen" Windows form

 

OracleConnection conn = new OracleConnection();

conn.ConnectionString = "User Id=" + lblUserID.Text +

                                        ";Password=" + txtPassword.Text +

                                      ";Data Source=" + "testDatabase;";

.. 

try

{

conn.Open();

..
..
it works fine.  The problem is once they authenticate I want to open up a new windows form and execute queries there, but my connection is lost and in my code on the new form states that my connection "conn does not exist in the current content.

_cmd = new OracleCommand(sqlBuildString, conn)

 How can you preserve your connection to multiple windowns once you have open it on your main Windows form (Sign in Screen)
Thanks I am new at this, that is why... 

Answers (1)