本人买了本书《asp.net从入门到精通》,在学水晶报表,照着书中敲代码,但是始终报“DataSet1TableAdapters.goodsTypeTableAdapter 不包含Connection的定义”,请各位高手帮帮忙吧,本人先道谢了
代码如下所示
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
using DataSet1TableAdapters;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        using (SqlConnection con = new SqlConnection("database=xiaoma;server=.;uid=sa;pwd=123;"))
        {
            DataSet1 ds = new DataSet1();//建立空白数据集对象
            DataSet1TableAdapters.goodsInfoTableAdapter info = new DataSet1TableAdapters.goodsInfoTableAdapter();
            info.Connection = con;
            info.Fill(ds.goodsInfo);
            DataSet1TableAdapters.goodsTypeTableAdapter type = new goodsTypeTableAdapter();
            type.Connection = con;
            type.Fill(ds.goodsType);
            SqlDataAdapter ad = new SqlDataAdapter();
            ad.SelectCommand = new SqlCommand();
            ad.SelectCommand.Connection = con;
            ad.SelectCommand.CommandText = "select * from goodsInfo inner join goodsType on goodsInfo.typeId=goodsType.typeId";
            ad.Fill(ds);
            //声明ReportDocument对象,与水晶报表中的数据交互
            ReportDocument doc = new ReportDocument();
            //加载水晶报表
            doc.Load(Server.MapPath("CrystalReport2.rpt"));
            //设置水晶报表数据源
            doc.SetDataSource(ds);
            doc.SummaryInfo.ReportTitle = "商品信息表";//设置报表标题
            doc.SummaryInfo.ReportAuthor = "何婷";//设置报表作者
            this.CrystalReportViewer1.ReportSource = doc;//将内容绑定给水晶报表
            this.CrystalReportViewer1.DataBind();        }
    }
}