Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - one-to-many insert tutorial request for asp.net
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

one-to-many insert tutorial request for asp.net

 Post Reply Post Reply
Author
imhotep View Drop Down
Groupie
Groupie
Avatar

Joined: 29 June 2003
Location: United States
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote imhotep Quote  Post ReplyReply Direct Link To This Post Topic: one-to-many insert tutorial request for asp.net
    Posted: 25 August 2006 at 5:32pm
Here is my dilima. I am kind of new to programming in asp.net, so bear with me. I am building a simple insertion script in asp.net and I am a little confused on how to properly carry out this coding.

I have a MS SQL Database
I have two tables
      tblAccount
      tblDirectory
In the tblAccount, the "accountID" is the primary key
It is also a foreign key in the tblDirectory

I want to be able to create accounts in the tblAccount table. In the asp.net application, I want the user to be able to login using the information they registered in the account table, and then enter data in the tblDirectory table and that information still be attached to the "accountID" field in the tblAccount table.

This is for a simple directory application. In otherwords, I register for an account, and then I can login and see the details of my account. I have two businesses that I want to enter into the database. So I want to be able to come in, enter my first business and when that is loaded, I can come back and enter my second business.

I think this is a one-to-many relationship in the database. Is there a tutorial on how to accomplish this using asp.net? I want to make sure that when the person logs in, only their information comes up and they can enter their businesses in the tblDirectory database.

Thanks in advance for your help.
Man Know Thyself
Back to Top
imhotep View Drop Down
Groupie
Groupie
Avatar

Joined: 29 June 2003
Location: United States
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote imhotep Quote  Post ReplyReply Direct Link To This Post Posted: 25 August 2006 at 6:35pm
Another question, if I create an account in the tblAccount table, will it automatically create an entry in the tblDirectory table, just with all of the other fields empty with the acception of the matching accountID table?
Man Know Thyself
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 26 August 2006 at 5:53pm
Information will not automatically be populated in the tblDirectory Table. When they signup, it just puts stuff in the tblAccount table if I understand you correctly. After that simply give them a form to add whatever they have to add to the tblDirectory Table. If you have accountID as a local variable use it as an insert parameter so do something like :: Insert INTO tblDirectory(accountid, info1, info2) Values (...)

On display in a datagrid or whatever you are using simply filter on :: where accountID=X

Not sure if this answer is too simple but I am not 100% clear what more complex you might be trying to accomplish.
Back to Top
imhotep View Drop Down
Groupie
Groupie
Avatar

Joined: 29 June 2003
Location: United States
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote imhotep Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2006 at 6:37pm
Thanks, this really helps 
Man Know Thyself
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.