未将对象引用为实例 报表的问题
public class Caigou_list : System.Web.UI.Page{
//protected CrystalDecisions.Web.CrystalReportViewer myCryReports;
private CrystalDecisions.CrystalReports.Engine.ReportDocument myRPDoc;
public int pramed;
//protected PeopleNetAccess myNetAccess;
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.PageBind ();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void PageBind()
{
string sqlstring = "select Produce_plan.caigou_id,Produce_plan.plan_year,Produce_plan.plan_area,Produce_plan.goods_num,Produce_plan.goods_danwei,Produce_plan.goods_price,Produce_plan.money,Produce_plan.plan_people,wupin.wp_name,wp_type.wp_type from Produce_plan,wupin,wp_type where Produce_plan.goods_name=wupin.wp_id and Produce_plan.goods_type=wp_type.type_id";
//Database db = new Database();
string con = "server=(local);database=lyjxc;User id=sa;Pwd=''";
SqlConnection myConn = new SqlConnection (con);
myConn.Open();
//this.myRPDoc.Load( Server.MapPath( "CryReports/Caigou_List.rpt" ) );
DataSet myDs = new DataSet();
//this.getTableData( sqlstring,ref myDs,"Produce_plan");
if(this.getTableData( sqlstring,ref myDs,"Produce_plan")==false)
{
Response.Write("<script language='javascript'>alert('插入成功!')</script>");
}
else
{
this.myRPDoc.SetDataSource( myDs );
this.CrystalReportViewer1.ReportSource = this.myRzPDoc;
this.CrystalReportViewer1.DataBind();
}
myConn.Close ();
}
protected bool getTableData( String strCommand , ref DataSet myDataSet , String TableName )
{
string con = "server=(local);database=lyjxc;User id=sa;Pwd=''";
SqlConnection myConn = new SqlConnection (con);
myConn.Open();
bool returnValue = true;
// DataSet returnValue;
SqlCommand myCommand = new SqlCommand( strCommand,myConn );
SqlDataAdapter myAdapter = new SqlDataAdapter( myCommand );
try
{
myAdapter.Fill( myDataSet,TableName );
}
catch
{
// returnValue = false;
}
return returnValue;
}
}
这是代码
我都不知道出现什么的问题,望各位大虾帮帮我