title: c sharp return object from function
body: <p>im facing a problem , when  i creat my own class i want to create Mysql connection function and i want to use it inside all my forms i do this </p>
  
  <p>program.cs </p>
  
  <pre><code>using MySql.Data.MySqlClient;
  using MySql.Data.Types;
  using System.Xml;
  using System.IO;
  public class testing
      {
          public string fahadt="Hello Class";
  
  
  
  
          public  void conncting()
          {
  
  
              MySqlConnection connection;
              string cs = @"server=localhost;userid=root;password=;database=taxi";
              connection = new MySqlConnection(cs);
              try
              {
  
                  connection.Open();
  
              }
              catch (MySqlException ex)
              {
                 // MessageBox.Show(ex.ToString());
              }
  
          }
  
      }
  </code></pre>
  
  <p>and in my form </p>
  
  <pre><code>private void button7_Click(object sender, EventArgs e)
          {
              testing fahad = new testing();
              try
              {
                  dataGridView1.Show();
                  fahad.conncting();
  
                  // here is error under fahad.conncting.createcommand();
                  MySqlCommand cmd = fahad.conncting.CreateCommand();
                  //cmd.CommandText = "SELECT * FROM  ocms_visitors WHERE `id`='"+textBox4.Text+"'";
                 // MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
                  //textBox4.Text = adap.id;
  
                 // DataSet ds = new DataSet();
                 // adap.Fill(ds);
  
                 // dataGridView1.DataSource = ds.Tables[0].DefaultView;
                  //MessageBox.Show("Yes Mysql Connection is Working Now  !");
              }
              catch (Exception)
              {
                  throw;
              }
  
          }
  </code></pre>
  
  <p>i dont know how i can do it im very new = C# </p>
  
  <p>please help me and also i have another q should i use 
  using .... in class and form or Enough in class ? </p>
  
  <p>thanks</p>