Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 7th, 2009, 06:47 PM
Registered User
 
Join Date: Jan 2009
Location: Charlotte, NC
Posts: 6
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via Yahoo to hughveal
Default Sample code needed for Professional ADO.NET with VB .NET

I have this book but could not find the sample code. Could someone e-mail it to me or tell me where to find it?
Reply With Quote
  #2 (permalink)  
Old February 7th, 2009, 08:04 PM
jminatel's Avatar
Wrox Staff
Points: 18,895, Level: 59
Points: 18,895, Level: 59 Points: 18,895, Level: 59 Points: 18,895, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 1,944
Thanks: 72
Thanked 139 Times in 101 Posts
Default

I think you are going to be out of luck unless you can find one of the authors who has this code. In 2003, APress acquired this book and many others from Wrox's former owners. Up until a few months ago, APress distributed the code. A few months ago, they stopped distributing the code for all of the Wrox books they own the rights to. We are not allowed to distribute their code.

They other option would be to return that old book and buy a current actual Wrox book on a current .NET version. That old book is .NET 1.0 era. Our 2 current Wrox ADO.NET books are:
Professional ADO.NET 2: Programming with SQL Server 2005, Oracle, and MySQL
and
Professional ADO.NET 3.5 with LINQ and the Entity Framework
and we have all the code you need for them.

Hope this helps.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!
Reply With Quote
  #3 (permalink)  
Old June 29th, 2009, 06:37 PM
Authorized User
 
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default Foreign key conatraint in database

Hi
I have 2 tables connected to each other and when i try to insert data int them from a vb form the foreign key relationship wont hold. Their respective primary keys are identity columns .
when data is inserted in the vb form the primary keys for both tables are generated.Foreign keys wont show.
I have created a data table with all the columns defined as well as the foreign key constraints but still nothing happens.

If anyone has dealt with a similar problem please advice as im reallly desperate to get this working and dont know what to do.

Please provide any code examples you might have as im new at dealing with programs and posting to forums.

Thanks in advance
Reply With Quote
  #4 (permalink)  
Old June 30th, 2009, 03:18 AM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

slake:
It would be very helpful for you to show your two tables with the Primary Key(s) and Foreign Key(s) identified. Without seeing the two tables, I am making the suggestion:
  • The ONLY way for two tables to have identical keys, in a RDMS (Relational Database Management System, is for TableA to have a Key identified as the Primary Key i.e. TableA (A_ID PK, Anext). and a TableB(B_ID PK, Bnext, A_ID FK). Note: Primary Key in Table is the Foreign Key in TableB. It is this relationship, 1-to-many, that the Primary Key and Foreign Key constraints will hold true for adds, inserts, updates and Cascade deletes.
Hope this helps. (This is the second attempt of responding to this thread)
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
Reply With Quote
  #5 (permalink)  
Old June 30th, 2009, 03:54 PM
Authorized User
 
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default FOREIGN KEY NOT INPUT IN TABLE FROM VB.NET

hi there
Really gald you could answer so promptly. This is the scenario

Cust(C_id,CName,Address) , Book(B_id,Title,Author,C_id). Now these are my two table. I am inserting data into from my form in VB. I do not have any text boxes for the primary keys as they are both identity columns. When i insert the CName,Address then Title,Author from the text boxes in VB the info is saved and primary keys for both tables created.
However. I need to have the Primary key of the Cust table automatically inserted into the Book table as a foreign key. For example

Cust(1,J.Smith,45 london str) Book(11,The drive,M.Andrews,1). In this eample i know the the primary keys will auto generate when the data in inserted but 1 will not appear as a foreign key in Book unless i go back into the table and manually insert it. In my case i need to create some from of function to insert it for me everytime insert data into my tables. My user needs to only enter the required data and not bother about primary or foreign keys . I read about triggers that can be created in the database. Im not sure if this will work and if it does how do i write one(Please advise with an example) or if there is any other way of doing it.Please advise.

Thanks again in advance. i appreciate the help.

Kind regards

Slake
Reply With Quote
  #6 (permalink)  
Old June 30th, 2009, 06:13 PM
Authorized User
 
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default foreign key works but other data wont appear

Hi
I have created the trigger for my problem but then when i insert it all the other columns wont appear. Exampl

Student(studid,name,address) course(cid,coursename,date,stuid)
studid and cid are primary keys in there respective tables and forign key (studid) in course.

when i insert the vales in for everything except the primary and foreign key. all vales in the parent(student) table are generated.The child table will generate the first column with the foreign key and then another column without a foreign key.
So for every single parent column i generate 2 columns of the child table. Each having half of what i want. I need all the data to be insert in the same column


[CREATE TRIGGER TG_INS_STUDENT

ON dbo.STUDENT
FOR
INSERT
AS
BEGIN

INSERT INTO dbo.COURSE(STUDID)
SELECT STUDID FROM INSERTED
END]

please help me rectify it if you can i came so close.Look forwaard to hearing from you.

Last edited by slake; June 30th, 2009 at 06:40 PM.. Reason: Realised an error with the insertion
Reply With Quote
  #7 (permalink)  
Old July 1st, 2009, 05:00 AM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default FOREIGN KEY NOT INPUT IN TABLE FROM VB.NET

Slake:

Thanks for the detail. One of your problems is due to the fact the relationship is not correct. What if the book is read, or bought by more than one Customer? In my opinion, the relationship between your Customer and your Book tables are many-to-many. You need a junction table:
Code:
 
CustTbl( C_id, CName, CAddress)---<CustBkTbl(CusBkID,C_id,B_id)>----BkTbl(B_id,....)
 
In the Book Table I removed the C_id and placed it in the junction table, CustBkTbl. The junction allows for the Customer to buy/read 1 or more books and it allows for the 1 or more Books to be read/bought by more than one Customer. The -----< & >----- indicates the relationships between the 3 tables.
Another situation I see in your Book Table is with the Author in that you may have more than 1 author per book....as in many WROX books, for example. To rectify that build the following::
AuthorTbl (authorID, author name) and AuthorBookTbl(aubkID, authorID,B_id), which is the junction table for Author and Book, the BkTbl(B_id,Title, ISBN).

Remember: "....The KEY is the KEY', from 70's movie Jumpin' Jack Flash

Hope this hellps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.

Last edited by peace95; July 1st, 2009 at 05:33 AM..
Reply With Quote
  #8 (permalink)  
Old July 1st, 2009, 05:29 AM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default foreign key works but other data wont appear

Slake:

You need to use the junction table between your Student Tasble or Entity and the Course Table or Entity. Remember to remove the Student ID from the Course Table. Follow instructions in previous response.

I forgot to mention, the tables on the right and left of the junction table MUST exist or be defined in the database BEFORE defining the junction table, the one in the middle,. Also in your forms you can use the Book, Author, Customer and Course Tables as LOVs after you populate them.

Redefine your RDBMS schemes...... Yes you are very close.....Don't Give Up!!

Hope This Helps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
Reply With Quote
  #9 (permalink)  
Old July 1st, 2009, 06:00 PM
Authorized User
 
Join Date: Jun 2009
Posts: 13
Thanks: 2
Thanked 0 Times in 0 Posts
Default foreign key constraint in sql

Hi Peace
Thanks for the helpon breaking the tables down. That i have done but i still need to auto generate the foreign keys of these relationships automatically. In ms sql i manually insert them as the primary keys are auto generated. I tried to write an insert trigger which did not work as i expected though it auto generated the foreign key but after the original data was inserted.

Do you know how to resdolve this issue please. If so let me know.I will be so greatful

Kind Regards

Slake
Reply With Quote
  #10 (permalink)  
Old July 1st, 2009, 09:01 PM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default foreign key constraint in sql

Slake:
It sounds as if the problem or problems are in the Database Tables. Did you define the relationships between the tables? If not, this MUST be done. Is the RDBMS Oracle or MS SQL? I thought it was Oracle. Let me know.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample code Professional ADO.NET Programming YUKOS All Other Wrox Books 6 January 30th, 2013 01:47 AM
Sample Code needed for C# Web Applications with VS .NET hughveal C# 1 February 7th, 2009 08:58 PM
Professional ADO.NET Programming source code pitzu1023 All Other Wrox Books 2 May 15th, 2006 08:19 AM
how to download code for Professional ADO.NET....? bobcow Wrox Book Feedback 1 July 19th, 2005 12:54 PM
can't find sample code r professional ADO.net prog calvinpost ADO.NET 2 January 27th, 2004 04:01 AM



All times are GMT -4. The time now is 05:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.