2

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

2
  • What is the current platform your project is aimed at? Check the properties, you may have it lower than 3.5?
    – Derek
    Jul 11, 2012 at 7:46
  • Does the error really read "Ling", with a G? It should be Linq, with a Q.
    – J.P.
    Jul 11, 2012 at 7:49

1 Answer 1

4

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

2
  • 1
    I did what you said, then I am getting a runtime error."Login failed for user 'IIS APPPOOL\DefaultAppPool'" . What am I missing, I used windows authentication
    – Tamseyc
    Jul 11, 2012 at 8:17
  • You probably need to set the identity on your application pool, but I think it's better to create a separate question for this problem. Jul 11, 2012 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.