日期:2014-05-18  浏览次数:20807 次

VS2008中缺少引用, 求助各位大神
找不到类型或命名空间名称“WeatherDataClassesDataContext”(是否缺少 using 指令或程序集引用?)


程序代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.DataSetExtensions;
using System.Data.Entity;
using System.Data.Linq;
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;

namespace _555555
{
  public partial class _Default : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)  
  {
  Bind();
  }
  }
  ///<summary>
  /// 数据绑定
  /// </summary>
  private void Bind()
  {
  // LINQ to SQL
  WeatherDataClassesDataContext ndc = new WeatherDataClassesDataContext();
  var query = from em in ndc.Weather //查询数据
  select new
  {
  em.CMD_ID,
  em.Component_ID,
  em.Timestamp,
  em.Average_WindSpeed_10min,
  em.Average_WindDirection_10min,
  em.Max_WindSpeed,
  em.Extreme_WindSpeed,
  em.Standard_WindSpeed,
  em.Air_Temperature,
  em.Humidity,
  em.Air_Pressure,
  em.Precipitation,
  em.Precipitation_Intensity,
  em.Radiation_Intensity,
  em.Alerm_Flag
  };
  GridView1.DataSource = query;
  GridView1.DataBind();
  }
  }
}

------解决方案--------------------
先 private DataClasses1DataContext ndc;//优点是其他方法也可使用


然后方法里


ndc = new DataClasses1DataContext();
var query = from em in ndc.Weather //查询数据
select new
{
 。。。。。
或者直接
DataClasses1DataContext ndc = new DataClasses1DataContext();
var query = from em in ndc.Weather //查询数据
select new
{
 。。。。。


------解决方案--------------------
你有没在 解决方案管理器--添加--新项---linq to sql类,再把数据库的表拖进去DataClasses1.dbml?
------解决方案--------------------
看看你的bin debug里面有没有。没有去问别人要一个。