Print Page | Close Window

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

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=21137
Printed Date: 29 March 2026 at 8:42am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: one-to-many insert tutorial request for asp.net
Posted By: imhotep
Subject: one-to-many insert tutorial request for asp.net
Date 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



Replies:
Posted By: imhotep
Date 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


Posted By: michael
Date 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.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: imhotep
Date Posted: 28 August 2006 at 6:37pm
Thanks, this really helps 

-------------
Man Know Thyself



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net