SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Il tipo 'System.Data.Common.DbConnection' è definito in un assembly di cui manca il riferimento.

Last post 03-28-2017 4:19 PM by MorFor. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-28-2017 11:36 AM

    Il tipo 'System.Data.Common.DbConnection' è definito in un assembly di cui manca il riferimento.

    I would like to start using SharpDevelop

    But in my test project I added the reference System.Data.SqlServerCe

    This is my project

    /*
     * Creato da SharpDevelop.
     * Utente: Marco
     * Data: 27/03/2017
     * Ora: 9.59
     *
     * To change this template use Tools | Options | Coding | Edit Standard Headers.
     */
     
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.Common;
    using System.IO;
    using System.Data.SqlServerCe;

    namespace prova
    {

        /// <summary>
        /// Description of MainForm.
        /// </summary>
        public partial class MainForm : Form
        {
            public static void Main(string[ args)
            {
                Application.Run(new MainForm());
            }
           
            public MainForm()
            {
                //
                // The InitializeComponent() call is required for Windows Forms designer support.
                //
                InitializeComponent();


     

                //
                // TODO: Add constructor code after the InitializeComponent() call.
                //
            }
           
            void Button1Click(object sender, EventArgs e)
            {
               
                            SqlCeConnection conn = null;
                try
                    {
                    conn = new SqlCeConnection("Data Source=Server2008; Integrated Security=SSPI; Initial Catalog=cmfspa;User Id=sa;Password=martina02");
                    con.Open();
                    SqlCeCommand cmd = con.CreateCommand();
                    cmd.CommandText="SELECT ar_descr, ar_desint, ar_codart, ar_ubicaz FROM artico WHERE ar_codart = '" + Codice_articolo.ToUpper().Trim() + "' , con";
                    cmd.ExecuteNonQuery();
                   
                }
                finally
                    {
                    con.Close();
                        }
            }
        }
    }

    I error in

    SqlCeConnection conn = null;

    and

    SqlCeCommand cmd = con.CreateCommand();

    the error for SqlCeConnection and SqlCeCommand is

    The 'System.Data.Common.DbConnection' type is defined in an assembly of which the reference is missing. Add an assembly reference 'System.Data, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089'. (CS0012)

  • 03-28-2017 4:19 PM In reply to

    • MorFor
    • Top 500 Contributor
    • Joined on 04-15-2008
    • Posts 9

    Re: Il tipo 'System.Data.Common.DbConnection' è definito in un assembly di cui manca il riferimento.

    In sostanza dice che non hai aggiunto il riferimento all'assembly, tu sei sicuro di averlo aggiunto al progetto?

    Progetto->Aggiungi Riferimento e poi nella finestra che si apre cercalo e procedi all'aggiunta.

    Comunque questo è un forum in inglese ;)

     

    "Eng" version (not so good english!):

    You need to add assembly reference, from menù project -> add reference then select the oone you need

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.