1
votes

I have the following code in c#.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Data;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using V2.PaidTimeOffDAL;

    public partial class _Default : System.Web.UI.Page 
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnView_Click(object sender, EventArgs e)
    {

        HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext();
        var userAccounts =
        from u in db.BMS_Users
        select u;
        GridView1.DataSource = userAccounts;
        GridView1.DataBind();

    }
    }

Whenever I test, I get the following error "System.Data.Linq.DataContent is defined in an assembly that is not referenced. You must add a reference to an assemply 'System.Data.Linq Version=3.5.0.0' Culture=Neutral PublicKeyToken=############".

Whenever I try to add a directive using System.Data.Linq I get following error "The type or namespace name 'Ling' does not exist in the namespace 'System.Data'"

I am new to LINQ to SQL. Please assist

1
What is the current platform your project is aimed at? Check the properties, you may have it lower than 3.5?Derek
Does the error really read "Ling", with a G? It should be Linq, with a Q.J.P. ten Berge

1 Answers

3
votes

You will need to add a reference to System.Data.Linq assembly as well. Writing the using statement alone is not enough.