-
Jul 22nd, 2007, 07:49 PM
#1
Thread Starter
Junior Member
[RESOLVED] [2005] Relating Tables in a Dataset
I'm trying to create a dataset with multiple tables that are related by an ID field.
In the main table I'm setting auto increment to the first column and calling that column 'custID' , but when I create another table and try to put a 'custID' field in I get an error saying I can't have the same column name in two different tables.
how do I connect the two tables together so they both contain the 'custID' number?
-
Jul 22nd, 2007, 10:55 PM
#2
Re: [2005] Relating Tables in a Dataset
You can generate relations in your DataSet by just dragging fields from one table to another directly in the designer.
-
Jul 24th, 2007, 10:29 AM
#3
Thread Starter
Junior Member
Re: [2005] Relating Tables in a Dataset
I'm still a little confused.
Wouldn't a normal relational database have a detail table with 'CustID', 'name', 'address', ... All the basic customer information.
And then, say, an order table with 'CustID', 'item', 'Qty', '$Amount',... All the order information for each order.
Why won't VB let me create two tables with a 'CustID' field?
When I try to create a second table in a Dataset with the ID field it gives me an error saying:
"Identifier 'CustID ' is not valid."
-
Jul 24th, 2007, 11:16 AM
#4
Re: [2005] Relating Tables in a Dataset
Show your code please... It's very hard to debug without seeing what's going.
-
Jul 24th, 2007, 12:00 PM
#5
Thread Starter
Junior Member
Re: [2005] Relating Tables in a Dataset
There is no code to show.
I double clicked on dataset to add to the form. Then I go into the dataset's properties and go into the Tables collection, add a first table with fields. Then I add a second table and try to call the first field the same name as the first field in the first table and I get the error.
-
Jul 24th, 2007, 01:41 PM
#6
Re: [2005] Relating Tables in a Dataset
Originally Posted by vb3119
There is no code to show.
I double clicked on dataset to add to the form. Then I go into the dataset's properties and go into the Tables collection, add a first table with fields. Then I add a second table and try to call the first field the same name as the first field in the first table and I get the error.
I've just tried to replicate the error by doing the same steps as you described but everything was fine... No error whatsoever...
-
Jul 24th, 2007, 06:07 PM
#7
Thread Starter
Junior Member
Re: [2005] Relating Tables in a Dataset
That's strange. Here's what I'm doing step by step.
(I'm running this in VB2005 express)
Open new windows app
Double click on DataSet (select untyped dataset)
In DataSet1 properties:
Click on 'Tables' collection
click add (creates table1)
in table1 I click on Columns collection
add column,
change the '(name)' field under the 'design' section (not the 'Column name') to 'CustID'
add a second column 'desc'
Now,
I get out of table1 and add another table, table2
in table2 I add one column.
Change the (name) field under the 'design' section to 'CustID'
I then get an error:
-
Jul 24th, 2007, 06:33 PM
#8
Re: [2005] Relating Tables in a Dataset
Aha! That's like trying to name two different TextBoxes both "TextBox1." You can't do it.
Add one table and add one column and don't change anything. Add another table and column and you'll see the second column in Table2 is called DataColumn2 even though it is in a different table.
Change the names and just name the Columns different things.
-
Jul 24th, 2007, 06:45 PM
#9
Thread Starter
Junior Member
Re: [2005] Relating Tables in a Dataset
Ahh!!
That was the problem. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|