title: "Cannot implicitly convert type IDbConnection to SqlConnection"
body: <p>I need some help please.</p>
  
  <p>I tried make an <code>INSERT</code> into my SQL database but I can't because give me an error in this code line:</p>
  
  <pre><code> commandoSQL.Connection = dbcon;
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Assets/NGUI/Scripts/Interaction/ChamarVariavel.cs(43,29): error CS0266: Cannot implicitly convert type <code>System.Data.IDbConnection' to</code>System.Data.SqlClient.SqlConnection'. An explicit conversion exists (are you missing a cast?)"</p>
  </blockquote>
  
  <p>I hope somebody can help me with this.</p>
  
  <p>Thanks</p>
  
  <p>My code:</p>
  
  <pre><code>public class ChamarVariavel : MonoBehaviour {
  
      public UISlider slider;
  
      // Use this for initialization
      void Start () {
      }
  
      // Update is called once per frame
      void Update () {
      }
  
      void OnGUI(){
          // Connection DB
          string connectionString = "Data Source=(local);Initial Catalog=Test;User ID=******;Password=*******";
  
          IDbConnection dbcon;
  
          dbcon= new SqlConnection(connectionString);
  
          dbcon.Open();
          //DB Online
  
          float x = slider.value * 100;
          GUI.Label(new Rect( 570, 238, 70, 30 ), "(" + x.ToString("f2") + ")");
  
          string qInsert = string.Format(@"INSERT INTO Fuel (fuel) VALUES ('{0}')", x);
  
          SqlCommand commandoSQL = new SqlCommand(qInsert);
  
          commandoSQL.Connection = dbcon;
  
          try
          {
              commandoSQL.ExecuteNonQuery();
          }
          catch (Exception ex)
          {
              GUI.Label(new Rect( 300, 40, 300, 300 ), ex.ToString());
          }
  
          dbcon.Close();
          //DB offline
      }
  }
  </code></pre>