Tamseyc
Tamseyc

Reputation: 445

LINQ to SQL System.Data.Linq.DataContext not referenced

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

Upvotes: 2

Views: 7147

Answers (1)

Gerrie Schenck
Gerrie Schenck

Reputation: 22368

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

Upvotes: 4

Related Questions