Jagjit Saini

Jagjit Saini

  • NA
  • 196
  • 37.5k

Err - The type or namespace name SampleDataContext could not be found.

Feb 21 2022 1:02 PM

Hi

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyApps
{
    public partial class MyForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SampleDataContext dbContext = new SampleDataContext();
            GridView1.DataSource = from Ordr in dbContext.
                                   select Ordr;
            GridView1.DataBind();
        }
    }
}

******************************************************

namespace MyApps
{
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Data;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Linq;
    using System.Linq.Expressions;
    using System.ComponentModel;
    using System;
    
    
    [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Test")]
    public partial class SampleDataContext : System.Data.Linq.DataContext
    {
        
        private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
        
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertORDR(ORDR instance);
    partial void UpdateORDR(ORDR instance);
    partial void DeleteORDR(ORDR instance);
    #endregion
        
        public SampleDataContext() : 
                base(global::System.Configuration.ConfigurationManager.ConnectionStrings[TestConnectionString"].ConnectionString, mappingSource)
        {
            OnCreated();
        }

}

}

Thanks


Answers (5)