简体   繁体   English

我没有解决“必须声明一个主体,因为它没有被标记为抽象,外部或部分”的问题吗?

[英]i don't solve “must declare a body because it is not marked abstract, extern, or partial” problem?

How can i solve "must declare a body because it is not marked abstract, extern, or partial". 我该如何解决“必须声明一个主体,因为它没有被标记为抽象,外部或部分”。 This problem. 这个问题。 Can you show me some advices? 你能给我一些建议吗?

Full Error message is about Save, Update, Delete, Select events... 完整错误消息是关于保存,更新,删除,选择事件...

Full message sample : 完整的消息样本:

GenoTip.DAL._AccessorForSQL.Save(string, System.Collections.Specialized.ListDictionary, System.Data.CommandType)' must declare a body because it is not marked abstract, extern, or partial GenoTip.DAL._AccessorForSQL.Save(string,System.Collections.Specialized.ListDictionary,System.Data.CommandType)'必须声明一个主体,因为它没有被标记为抽象,外部或部分

This error also return in Update, Delete, Select... 此错误还会在更新,删除,选择...中返回。

 public abstract class _AccessorForSQL
    {
        public virtual bool Save(string sp, ListDictionary ld, CommandType cmdType);
       public virtual bool Update();
       public virtual bool Delete();
       public virtual DataSet Select();
    }

    class GenAccessor : _AccessorForSQL
    {
        DataSet ds;
        DataTable dt;
        public override bool Save(string sp, ListDictionary ld, CommandType cmdType)
        {
            SqlConnection con = null;
            SqlCommand cmd = null;
            SqlDataReader dr = null;
            try
            {
                con = GetConnection();
                cmd = new SqlCommand(sp, con);
                con.Open();
                cmd.CommandType = cmdType;
                foreach (string ky in ld.Keys)
                {
                    cmd.Parameters.AddWithValue(ky, ld[ky]);
                }
                dr = cmd.ExecuteReader();
                ds = new DataSet();
                dt = new DataTable();
                ds.Tables.Add(dt);
                ds.Load(dr, LoadOption.OverwriteChanges, dt);

            }
            catch (Exception exp)
            {

                HttpContext.Current.Trace.Warn("Error in GetCustomerByID()", exp.Message, exp);
            }
            finally
            {
                if (dr != null) dr.Close();
                if (con != null) con.Close();

            }
            return (ds.Tables[0].Rows.Count > 0) ? true : false;

        }
        public override bool Update()
        {
            return true;
        }
        public override bool Delete()
        {
            return true;
        }
        public override DataSet Select()
        {
            DataSet dst = new DataSet();
            return dst;
        }


        private static SqlConnection GetConnection()
        {
            string connStr = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection conn = new SqlConnection(connStr);
            return conn;
        }

要么将它们标记为抽象,要么给它们一个空的身体。

Your methods Save, Update, Delete and Select don't have bodies. 您的方法“保存”,“更新”,“删除”和“选择”没有正文。 You need to either mark them as abstract or give them bodies (ie implement them). 您需要将它们标记为抽象或赋予它们主体(即实现它们)。

"virtual" methods can be overridden, but don't need to be. “虚拟”方法可以被覆盖,但不是必须的 Therefore you need to specify a method body. 因此,您需要指定一个方法主体。

If you just want to specify method signatures, declare them as "abstract". 如果只想指定方法签名,则将它们声明为“抽象”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#“必须声明一个主体,因为它没有被标记为抽象、外部或部分” - C# “must declare a body because it is not marked abstract, extern, or partial” 必须声明一个主体,因为它没有标记为抽象外部或局部 - must declare a body because it is not marked abstract extern or partial 错误:必须声明一个主体,因为它没有被标记为抽象,外部或局部 - Error: must declare a body because it is not marked abstract, extern, or partial C#必须声明一个主体,因为它没有被标记为抽象,外部或部分 - C# must declare a body because it is not marked abstract, extern, or partial 它说我需要声明一个主体,因为该类未标记为抽象,外部或局部,而且我不知道那意味着什么 - It says I need to declare a body because the class is not marked as abstract, extern, or partial, and I don't know what that means struct Cat(string,string,bool,bool)'必须声明一个主体,因为它没有被标记为abstract,extern或局部 - struct Cat(string, string, bool, bool)' must declare a body because it is not marked abstract, extern, or partial DispatcherTimer.Start()'必须声明一个主体,因为它在MVC4中未标记为抽象,外部或部分 - DispatcherTimer.Start()' must declare a body because it is not marked abstract, extern, or partial in MVC4 “warp(Vector3)”必须声明一个主体,因为它没有标记为抽象、外部或部分 - 'warp(Vector3)' must declare a body because it is not marked abstract, extern, or partial C# 错误:声明一个主体,因为它没有标记为抽象、外部或部分 - C# errors: declare a body because it is not marked abstract, extern, or partial 必须声明一个主体,因为它没有标记为抽象,外部或部分 - Must declare a body becase it is not marked abstract, extern or partial
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM