How to access TableAdaptors in XSD

You have created XSD file that has table and TableAdaptor. Now you want to access data in your C# code. You have to use Table DataSetTableAdapters namespace to access these adaptors. Example

using DataSetTableAdapters;

public partial class AllProducts : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
        GridView1.DataSource = productsAdapter.GetProducts();

This method works in Visual Studio 2013. In earlier version you have to use their respective namespace. This tip is particularly helpful if you are following this Microsoft Tutorial about DAL which give me trouble because I could not access the XSD file. Turned out the way it is accessed has changed in Visual Studio.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s