Solved

Datasets - using fillschema method

Posted on 2004-09-08
5
299 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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