3
Answers

Question about certain line -> using NorthwindTableAdapters; // Data Access Layer/logic

Tommy Bell

Tommy Bell

14y
7.1k
1
Im trying to make a simple site, that will get its content from a database, following the tutorial from MSDN(http://msdn2.microsoft.com/en-us/library/aa581776.aspx), where they use a northwind sample site - I can get it working fine.

However, when I attempt to apply the same tecniques to my own site, it doesnt work. I have narrowed it down to the following problem

In the sample project, they use a NorthwindTableAdator

using northwindtableadaptor;

This I can figure out where comes from, or how i get to use the adaptors that will make my project work, I cant seem to find out where I have to define the tableadaptors, I've built a tableadaptor and it can pull informaiton out of my database, and I have included the code in the codebehind file, of the page I am trying to show the information on, as follows.
My database is enkelt.mdf
my tablename -> project

in my app_code folder i have an 'ShowProjectList.xsd' where my tableadaptor is defined in as follows:

Projects <- title
ProjectTitle <- row in table
ProjectAuthor <- row in table

ProjectTableAdaptor
Fill, GetProjectList() <- methods


ShowProjects.cs:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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;
//notice we are missing the 'using NorthwindTableAdapters;' that the sample project has
//and I do not know what to put there instead to make my project work

public partial class ShowProjects : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //intended here is to give a list of projects in the database
        ProjectTableAdapter projectsAdapter = new ProjectTableAdapter();
        ListView1.DataSource = projectsAdapter.GetProjectList();
        ListView1.DataBind();
    }
}

An attempt to compile this will result in the following error:
Error    1    The type or namespace name 'ProjectTableAdapter' could not be found (are you missing a using directive or an assembly reference?)    G:\page\ShowProjects.aspx.cs    20    9    G:\page\

So, any ideas on what I have to do, or what I have to read so I can find out what I need to do to make this work?

Answers (3)