Solved

Help with first Typed Dataset test app

Posted on 2006-06-25
5
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 16982385
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
ID: 16982892
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
ID: 16983406
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
ID: 16987339
is quite likely ds.tbl_products
0
 
LVL 9

Expert Comment

by:lojk
ID: 16987349
or ds.tbl_productsDatatable
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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