Solved

Help with first Typed Dataset test app

Posted on 2006-06-25
5
218 Views
Last Modified: 2011-09-20
I am trying to use Typed Datasets now.

So far I am not sure what to do next.  This article talks about the wizard helping y ou to create TableAdapters and such but I'm using VS 2003: http://www.asp.net/learn/dataaccess/tutorial01vb.aspx?tabid=63

I am using VS 2003 and SQL Server 2005

I have:
1) Created a new web project and dragged a DataGrid onto it called dgProducts
2) created a Typed Dataset (TDSTest.xsd) that contains 3 tables (Products, Categories, and Products_Categories), related to each other with PKs and FKs
3) Compiled my .xsd by right clicking on it when viewing the .xsd in design view and selected "Generate Dataset".
3) Put this into the code-behind of my aspx page:

Imports System
Imports System.Configuration
Imports System.Data
Imports System.Text
Imports System.Data.SqlClient
Imports System.Web.Mail

Public Class WebForm1
    Inherits System.Web.UI.Page

    Dim DS As DataSet
    Dim Conn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("TestConn"))
    Dim da As SqlDataAdapter
    Dim cmd As SqlCommand

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Conn.Open()
        da = New SqlDataAdapter("GetProducts", Conn)
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        DS = New TDSTest

        da.Fill(DS, "Products")

        dgProducts.DataSource = DS.     <----- PROBLEM IS HERE UNLESS I'M NOT DOING OTHER THINGS RIGHT ABOVE OR BELOW
        dgProducts.DataBind()

        Conn.Close()
    End Sub

End Class

I am not sure what I'm doing wrong but Intellisense isn't showing the Product table when I do DS.     it shows the following:
http://www.webfound.net/notshowing_productstable.jpg - my code-behind
http://www.webfound.net/typed_dataset_page.jpg - my typed dataset in design view

Not sure what I'm missing or doing wrong here...
0
Comment
Question by:dba123
  • 3
5 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
Comment Utility
You're declaring DS as a standard dataset (not the typed dataset you created).   Change this:
 
   Dim DS As DataSet

To:

   Dim DS As TDSTest


 
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
clockwatcher is spot on, because your TDSDataset is inherited from the dataset VS knows how to handle some of its functionality but wont add work quite right because it is only expecting the types and methods defined within a stanadrd dataset, not an inherited one with additional tables and methods..

There is nothing stopping you from doing ds.tables("tablename) but then that defeats the point of making it strongly typed..
0
 
LVL 1

Author Comment

by:dba123
Comment Utility
yea, I have TDSTest for the dataset.  I still cannot see the tables after DS.

I want to be able to do DS.Products
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
is quite likely ds.tbl_products
0
 
LVL 9

Expert Comment

by:lojk
Comment Utility
or ds.tbl_productsDatatable
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now