title: Can I use same connection in my mainwindow in other windows? C# wpf mysql
body: <p>I have a problem, I am working on a C# WPF project which I need to connect to the MySQL database. I used to work with SQL Server with C# but since I need this project to upload/read data from an online databases I have to use MySQL, so I search on the net and find this solution:</p>
  <pre><code>using MySql.Data.MySqlClient;
      
  connString = &quot;SERVER=localhost;PORT=3306;DATABASE=test;UID=root;PASSWORD=;SslMode=none;&quot;;
              try
              {
                  conn = new MySqlConnection();
                  conn.ConnectionString = connString;
                  conn.Open();
                  MessageBox.Show(&quot;Connection Success&quot;);
              }
              catch (MySql.Data.MySqlClient.MySqlException ex)
              {
                  MessageBox.Show(ex.Message);
              }
  </code></pre>
  <p>I use it in my main window and it worked, now I have another question which is how can I use this connection on their windows? should I use the same code in all windows? or I can use it from the main window?
  for example, I have a DATAGRID in another window and I need to read the data from the database into the DATAGRID. how is this possible?</p>