Solved

Datasets - using fillschema method

Posted on 2004-09-08
5
296 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help converting a bitmap to an image in VB.Net 1 32
EF5: Question about Metadata Artifact Processing 4 15
VB.NET 1 21
get column names from table in vb.net 8 26
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

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