.net网站出现对象名无效的提示,怎么解决?
protected string GetVipCount()
{
return this.bC_About.GetVipCount_byC_Model("").ToString();
}
其中bC_About 是C_About对象,提示:对象名'C_About'无效!
类C_About如下:红色为该函数。。。
public class C_About
{
public C_About();
public int Add(C_AboutInfo model);
public IList<C_AboutInfo> C_AboutList_byUserId(string userId);
public bool Delete(int Id);
public C_AboutInfo GetModel(int id);
public C_AboutInfo GetModel(string userId);
public C_AboutInfo GetModel(int id, string userId);
public int GetVipCount_byC_Model(string c_model); public DataSet Select_byAdminSearch(string key, string tag, string c_city, string c_city1, string cx_model, string c_model, int c_vip, string order);
public DataTable SelectHotCommentList(int num, string cx_model);
public int SelectList_byPage(string type, string city1, string city2, string cx_model, string c_model, string c_huanjin, string c_money);
public DataTable SelectList_byPage(int PageSize, int PageIndex, string type, string city1, string city2, string cx_model, string c_model, string c_huanjin, string c_money);
public int SelectList_bySearch(string key, string tag, string city1, string city2, string cx_model, string c_model);
}
函数实现如下:
public int GetVipCount_byC_Model(string c_model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(id) from C_About ");
strSql.Append(" where 1=1");
strSql.Append(" and c_vip =1");
strSql.Append(" and eat_city ='0577'");
strSql.Append(" and c_pl >=0");
if (c_model != "")
{
strSql.Append(" and c_model like '%").Append(c_model).Append("%'");
}
SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@cx_model", SqlDbType.NVarChar, 50) };
parameters[0].Value = c_model;
return (int) DbHelperSQL.GetSingle(strSql.ToString());
}
public DataSet Select_byAdminSearch(string key, string tag, string c_city, string c_city1, string cx_model, string c_model, int c_vip, string order)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from c_about ");
strSql.Append(" where 1=1 ");
if (key != "")
{
strSql.Append(" and c_name like '%'+ @key +'%' or c_add like '%'+ @key +'%' or c_tel like '%'+ @key +'%' ");
}
if (tag != "")
{
strSql.Append(" and c_tag=@tag ");
}
if (c_city != "")
{
strSql.Append(" and c_city=@c_city ");
}
if (c_city1 != "")
{
strSql.Append(" and c_city_1=@c_city1 ");
}
if (cx_model != "")
{
strSql.Append(" and cx_model=@cx_model ");
}
if (c_model != "")
{
strSql.Append(" and c_model=@c_model ");
}
if (c_vip == 1)
{
strSql.Append(" and c_vip=@c_vip ");
}
else if (c_vip == 0)
{
strSql.Append(" and (c_vip='' or c_vip is null)");
}
if (order.ToLower() == "time")
{
strSql.Append(" order by c_time desc,id desc");
}
else if (order.ToLower() == "pl")
{
strSql.Append(" order by c_pl desc,id desc");
}
else if (order.ToLower() == "updatetime")
{
strSql.Append(" order by c_updateTime desc,id desc");
}
else
{
strSql.Append(" order by c_time desc");
}
SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@key", SqlDbType.NVarChar, 50), new SqlParameter("tag", SqlDbType.NVarChar, 50), new SqlParameter("@c_city", SqlDbType.NVarChar, 50), new SqlParameter("@c_city1", SqlDbType.NVarChar, 50), new SqlParameter("@cx_model", SqlDbType.NVarChar, 50), new SqlParameter("@c_model", SqlDbType.NVarChar, 50), new SqlParameter("@c_vip", SqlDbType.Int), new SqlParameter("@order", SqlDbType.NVarChar, 50) };
parameters[0].Value = key;
parameters[1].Value = tag;
parameters[2].Value = c_city;
parameters[3].Value = c_city1;
parameters[4].Value = cx_model;
parameters[5].Value = c_model;
parameters[6].Value = c_vip;
parameters[7].Value = order;
return DbHelperSQL.Query(strSql.ToString(), parameters);
}
public DataTable SelectHotCommentList(int num, string cx_model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top " + num.ToString() + " hits,Id ,c_name,c_commentCount from C_about");
strSql.Append(" where 1=1 ");
strSql.Append(" and eat_city='0577' ");
strSql.Append(" and c_pl>=0 ");
if (cx_model != "")
{
strSql.Append(" and cx_model=@cx_model ");
}
strSql.Append(" order by c_commentCount desc,Id desc");
SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@cx_model", SqlDbType.NVarChar, 50) };
parameters[0].Value = cx_model;
return DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];
}
public DataTable SelectIndex_byHotComment1(int num)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top " + num.ToString() + " c_commentCount,hits,Id,c_name from C_about");
strSql.Append(" where (cx_model='餐饮' or cx_model='娱乐') ");
strSql.Append(" and eat_city ='0577'");
strSql.Append(" and c_pl >=0");
strSql.Append(" order by c_commentCount desc,Id desc");
return DbHelperSQL.Query(strSql.ToString()).Tables[0];
}
--------------------编程问答-------------------- lz真小气,没有人会回答你的问题的,知识是有价的!! --------------------编程问答-------------------- 当时发的快了点,我现在想加分啊,但是提示要到改天了。。 这个问题困扰我好久。谢谢 --------------------编程问答-------------------- 支持一下 --------------------编程问答-------------------- 看看你的数据库登录的权限,如果权限不足或者权限过高(如果是dba的话登录以后默认是在DBO的系统表空间,用数据库.表名访问或者去掉DBA)
--------------------编程问答-------------------- this.bC_About
是不是这里bC_About实例还没有被实例化,或者没有添加相应的命名空间的引用? --------------------编程问答-------------------- ding
补充:.NET技术 , ASP.NET