i don't solve "must declare a body because it is not marked abstract, extern, or partial" problem?
Posted
by programmerist
on Stack Overflow
See other posts from Stack Overflow
or by programmerist
Published on 2010-03-23T12:56:39Z
Indexed on
2010/03/23
13:03 UTC
Read the original article
Hit count: 563
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
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;
}
© Stack Overflow or respective owner