引用类成员,提示不包含该成员的定义,但我有定义呀!有谁知道怎么解决吗?
帮帮忙,急!我定义的类为:
public class product
{
public product()
{}
public DataView GetProduct()
{
}
}
引用时出错:
编译器错误信息: CS0117: “product”并不包含“GetCProduct”的定义源错误:行 27: {
行 28: product myproduct = new product();
行 29: dg_product.DataSource = myproduct.GetCProduct(int.Parse(ViewState["categoryid"].ToString()));
行 30: dg_product.DataBind();
行 31: }
帮帮忙,急!我定义的类为:
public class product
{
public product()
{}
public DataView GetProduct()
{
}
}
引用时出错:
编译器错误信息: CS0117: “product”并不包含“GetCProduct”的定义源错误:行 27: {
行 28: product myproduct = new product();
行 29: dg_product.DataSource = myproduct.GetCProduct(int.Parse(ViewState["categoryid"].ToString()));
行 30: dg_product.DataBind();
行 31: }
解决方案 »
- 使用了response.write("")后 css样式失效
- 用了freetextbox控件往数据库中的插入记录的时候出现问题
- 中秋节,送分活动,请高人帮忙指点一下.
- 自动刷新网页中的session值不增加?为什么 ?
- 【VS 2005插件开发】【解决方案+技术】【纯技术问题】
- vs2005+sp1装好后运行不了下载asp的整站!
- 一个TextBox,内容是从数据库中提取的,显示给客户后,客户在TEXTBOX中进行了修改,修改后传过来的内容怎么还是从数据库中提取的内容?
- 加密解密(序列号)
- Crystal report viewer上的控制按钮图片显示不了,困扰了我好长时间,求各位高手帮忙!
- 哪位帮我找找这段代码的问题,急!!!
- ★非常苦恼的问题,大家给点思路吧!!
- 散200分问一个关于slickupload的问题
public class product
{
public product()
{}
public DataView GetCProduct(int pid)
{
}
}
问题仍在
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
using Dzone.DZshop.DB;
namespace Dzone
{
public class product:Base
{
public product()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public DataView getproduct()
{
String strsql;
DataSet myDs;
strsql = "SELECT category.categoryname ,productinfo.* from productinfo INNER JOIN category on productinfo.categoryid=category.categoryid";
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].DefaultView; }
//get category product
public SqlDataReader GetCProduct(int categoryid)
{
string strsql;
SqlDataReader result;
try
{
SqlConnection myCn = new SqlConnection(strConn);
strsql = "select * from productinfo where categoryid=" + categoryid;
SqlCommand myCm = new SqlCommand(strsql, myCn);
myCn.Open();
result = myCm.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
return result; }
//get a product
public DataRow GetAProduct(int Pid)
{
string strsql;
DataSet myDs;
try
{
strsql = "SELECT category.categoryname,productinfo.* from productinfo INNER JOIN category on productinfo.categoryid=category.categoryid where productinfo.productid=" + Pid;
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].Rows[0]; }
catch (System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
} }
//get the best sales 畅销产品
public DataView GetProductTop()
{
String strsql;
DataSet myDs;
strsql = "select top 10 productid,productname from productinfo order by sales desc";
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].DefaultView;
}
//get new product 最新产品
public DataView GetNewProduct()
{
string strsql;
DataSet myDs;
strsql = "select top 10 productid,productname from productinfo order by productid desc";
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].DefaultView;
}
//commend product 推荐产品
public SqlDataReader GetProductHits()
{
string strsql;
SqlDataReader result;
try
{
SqlConnection myCn = new SqlConnection(strConn);
strsql = "select top 10 productid,productname,intro=' '+SUBSTRING(intro,0,100)+'......',picture from productinfo order by hits desc";
SqlCommand myCm = new SqlCommand(strsql, myCn);
myCn.Open();
result = myCm.ExecuteReader(CommandBehavior.CloseConnection);
return result;
}
catch (System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
}
public DataRow gerp()
{
string strsql;
DataSet myDs;
try
{
strsql = "select * from productinfo ";
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].Rows[0]; }
catch (System.Data.SqlClient.SqlException er)
{
throw new Exception(er.Message);
}
}
}
public class category : Base
{
public category()
{ }
public DataView GetCategory()
{
String strsql;
DataSet myDs;
strsql = "select * from category order by categoryid";
myDs = ExecuteSql4Ds(strsql);
return myDs.Tables[0].DefaultView;
} }
}
引用的是:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dzone;
namespace DZshop
{
public partial class showcategory : System.Web.UI.Page
{
product myproduct = new product();
protected void Page_Load(object sender, EventArgs e)
{
ViewState["categoryid"] = Request.QueryString["category"];
GridBind();
}
private void GridBind()
{
SqlDataReader myDr;
myDr = myproduct.GetCProduct(int.Parse(ViewState["categoryid"].ToString()));
dg_product.DataSource = myDr;
dg_product.DataBind();
}
}
}
就会出错提示:编译器错误信息: CS0117: “product”并不包含“GetCProduct”的定义
把引用的dll先删除,重新build一下试试看
命名空间不一样,C#是区分大小写的
public DataView GetProductTop(){} public DataView GetCategory(){}
都可以。
下面的引用通过:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dzone;
namespace DZshop
{
public partial class left : System.Web.UI.UserControl
{
product myproduct=new product();
category mycategory=new category();
protected void Page_Load(object sender, EventArgs e)
{
if (!(this.IsPostBack))
{
GridBind();
}
}
private void GridBind()
{
DataView MyDv1;
DataView MyDv2;
MyDv1 = mycategory.GetCategory();
dg_category.DataSource = MyDv1;
dg_category.DataBind(); MyDv2 = myproduct.GetProductTop();
dg_sales.DataSource = MyDv2;
dg_sales.DataBind();
} }
}