Solved

Datasets - using fillschema method

Posted on 2004-09-08
5
297 Views
Last Modified: 2008-02-26
Newbie here!  I am creating a Budgeting app for my boss to use in our IT Department.  Currently, it is a simple Access database with a few tables, forms, and reports.  I have imported the data into sql and am working on making a web interface for entering all of our purchases/budget information.  I am trying to figure out the best way to get 5 sql tables into a dataset, along with specifying relationships.

Can I use the fillschema method on a data adaper for more than one table?  In other words, can I do something like this:

da.FillSchema(ds, SchemaType.Source, "Vendors")
da.FillSchema(ds, SchemaType.Source, "Invoices")

Also, I have a number of features I want to be able to do in my web app.  For instance, I want the user to be able to "add a vendor" and "add an invoice".  Should I create separate webpages for vendors and invoices or should I have one main page that gets changed dynamically depending on which feature the user clicks on?  

I hope I have explained myself clearly!  Thanks!
0
Comment
Question by:tsbathe
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Javert93
ID: 12029898
For the first question, you can't use FillSchema() to do what you want. Here is the easiest way (I think):

    1) Create a new component and drop an OleDataAdapter onto it (one for each table).
    2) Right-click on the component designer and choose "Generate DataSet..." from the context menu (or select it from the hyperlink in the properties window).
    3) In the "Generate DataSet" dialog, enter a class name for the dataset and check all the tables you want to include (the list will come from the data adapters).
    4) Once you click OK, the IDE will add a typed dataset class to your project, which you can use to store your data.
    5) Add a "Fill" method to you component class that accepts the typed dataset as a parameter and pass it into each of the data adapters you dropped on the component in the first step. Note that because the dataset contains multiple tables and relationships, it will enforce those relationships (event during a fill). So, you need to fill parent tables before you fill child tables, otherwise Fill() will throw an exception.
    6) Optionally, you should add an Update() method to you component that calls Update() on each of the data adapters if you are a planning to modify the data in the database.
    7) You can instantiate and use the component in your .NET code the same way you would use a class.

To answer the second question, I would recommend using different pages (it will make you life a lot easier).
0
 

Author Comment

by:tsbathe
ID: 12030116
A wonderfully complete answer!!!  You answered other questions I had too.  Filling the parent tables first, duh I should have realized!! Thanks!
0
 

Author Comment

by:tsbathe
ID: 12030328
One more question.  I just made the component (I've never made one before).  Is there a way I can reference the dataset in the component in design mode?  ie for specifying the datasource of a datagrid?
0
 
LVL 4

Accepted Solution

by:
Javert93 earned 50 total points
ID: 12030385
You can drop the dataset onto the Web Form Designer from the Solutions Explorer tree view. Then you should be able to reference it from the ASP.NET server controls using the properties window.
0
 

Author Comment

by:tsbathe
ID: 12030434
Thanks!!!!  This is great!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 1 28
Visual Studios 1 76
VB.net capture  result of a SQL query in variables 3 20
VB.net Adding a row to a DataGridView that has a checkbox column 5 23
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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