title: make a label static error : cannot access a non-static member of outer type 'windowsForm8.Form1' via nested Type 'windowsForm8.Form1.DBConnect'
body: <p>Yo this is my first post here and i wanna know how to fix this problem in C# 
  so im tryin to connect to database and select information from it and those information will be displayed as a label ! easy,
  so this is the error i get :<br/></p>
  
  <blockquote>
    <p>cannot access a non-static member of outer type 'windowsForm8.Form1'
    via nested Type 'windowsForm8.Form1.DBConnect'</p>
  </blockquote>
  
  <p><br/>and this is the Code :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using MySql.Data.MySqlClient;
  
  namespace WindowsFormsApplication8
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
  
      }
  
      public class DBConnect
      {
  
          private MySqlConnection connection;
          private string server;
          private string database;
          private string uid;
          private string password;
  
  
          //Constructor
          public DBConnect()
          {
              Initialize();
          }
  
          //Initialize values
          private void Initialize()
          {
              server = "net";
              database = "rainbow";
              uid = "ok";
              password = "passwd!";
              string connectionString;
              connectionString = "SERVER=" + server + ";" + "DATABASE=" +
              database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
  
              connection = new MySqlConnection(connectionString);
          }
  
          //open connection to database
          private bool OpenConnection()
          {
  
              try
              {
                  connection.Open();
                  return true;
              }
              catch (MySqlException ex)
              {
                  //When handling errors, you can your application's response based 
                  //on the error number.
                  //The two most common error numbers when connecting are as follows:
                  //0: Cannot connect to server.
                  //1045: Invalid user name and/or password.
                  switch (ex.Number)
                  {
                      case 0:
                          MessageBox.Show("Cannot connect to server.  Contact administrator");
                          break;
  
                      case 1045:
                          MessageBox.Show("Invalid username/password, please try again");
                          break;
                      default :
                          MessageBox.Show("Connected Successfuly!!");
                          break;
                  }
                  return false;
              }
  
  
          }
  
          //Close connection
          private bool CloseConnection()
          {
              try
              {
                  connection.Close();
                  return true;
              }
              catch (MySqlException ex)
              {
                  MessageBox.Show(ex.Message);
                  return false;
              }
          }
  
          //Insert statement
          public void Insert()
          {
              string query = "INSERT INTO mytable (username, password) VALUES('shryder', 'nopassword')";
  
              //open connection
              if (this.OpenConnection() == true)
              {
                  //create command and assign the query and connection from the constructor
                  MySqlCommand cmd = new MySqlCommand(query, connection);
  
                  //Execute command
                  cmd.ExecuteNonQuery();
  
                  //close connection
                  this.CloseConnection();
              }
          }
  
          //Update statement
          public void Update()
          {
          }
  
          //Delete statement
          public void Delete()
          {
  
          }
  
          //Select statement
          public List&lt;string&gt;[] Select()
          {
              string query = "SELECT * FROM mytable";
  
              //Create a list to store the result
              List&lt;string&gt;[] list = new List&lt;string&gt;[3];
              list[0] = new List&lt;string&gt;();
              list[1] = new List&lt;string&gt;();
              list[2] = new List&lt;string&gt;();
  
              //Open connection
              if (this.OpenConnection() == true)
              {
                  //Create Command
                  MySqlCommand cmd = new MySqlCommand(query, connection);
                  //Create a data reader and Execute the command
                  MySqlDataReader dataReader = cmd.ExecuteReader();
  
                  //Read the data and store them in the list
                  if (dataReader.Read())
                  {
                      /*list[0].Add(dataReader["username"] + "");
                      list[1].Add(dataReader["password"] + "");
                      list[2].Add(dataReader["email"] + "");*/
                      newscontent.Text = dataReader["username"]; //this is the error
  
  
                  }
  
                  //close Data Reader
                  dataReader.Close();
  
                  //close Connection
                  this.CloseConnection();
  
                  //return list to be displayed
                  return list;
              }
              else
              {
                  return list;
              }
          }
  
          //Count statement
  
  
          //Backup
          public void Backup()
          {
          }
  
          //Restore
          public void Restore()
          {
          }
      }
  
  
  
  }
  }
  </code></pre>
  
  <p>please help me
  ,thanks :)</p>