Solved

Help with first Typed Dataset test app

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

12 Experts available now in Live!

Get 1:1 Help Now