Solved

Help with first Typed Dataset test app

Posted on 2006-06-25
5
220 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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