Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with first Typed Dataset test app

Posted on 2006-06-25
5
Medium Priority
?
226 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

971 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