2 tables in 1 DataSet???

Black Tiger

New member
Joined
Jan 24, 2003
Messages
2
Location
Mantova - Italy
Hi, Im in a big trouble...

Ive to use a dataset with two tables (cose I need to perform a relation "OneToMany" between these tables...), but I dont know how I can do it...

Can you help me please??? :(

Thank you a Ton...:D
 
I guess it greatly depends on how youre creating your dataset. For example, I always inherit from a dataset and build the tables in code. For this I have a BuildDataTables() method in my inherited dataset that I call from the constructor. I also have separate friend methods that create single tables ( i needed them to be friend because sometimes I create them outside the dataset).

The BuildDataTables routine looks something like this:
Code:
        Protected Overridable Sub BuildDataTables()
            Me.Tables.Add(BuildProductsTable())
            Me.Tables.Add(BuildOrdersTable())

            Me.Relations.Add(PRODUCTS_ORDER_RELATION, _
                        Me.Tables(PRODUCTS_TABLE).Columns(PRODUCT_ID), _
                        Me.Tables(ORDERS_TABLE).Columns(ORDERID))

        End Sub
If youre creating your datasets using the schema designer, I think its as simple as just draggin another element on the designer page.
 
Its OK, but...
If have I still the database???

So I have an Access 2000 Database, and I need to perform that operation (the relation between the 2 tables inside the database...)

How I can do it???:confused:

I tried to do a test with a Dbconnection, a DataAdapter and a DataSet...:confused:

But theres an error...The debugger says that theres an exception...:(
 
If you do the join inside the database, youll return a single table with the joined results. If thats what you want just do a join
SELECT * FROM tblTable1 LEFT JOIN tblTable2 on tblTable1.fkTbl2=tblTable2.ID

Use the select as the text of your select command. Is that what you want?
 
The Dataset is only a sort of image of the database. Is the relation present in the Database?

If it is not, then you might easily get an exception in the code, when you try to define the relation - but the data in the tables does not fulfill that requirement!

Btw. Your debugger is probably a bit more precise than just saying "theres an exception", right? :-)
 
Back
Top