Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone have a good tutorial to learn how to add a record into an SQL database? The database is laid out with one primary key table and 9 foreign key tables that are related to it, or I suppose that it relates to.

I know how to insert data from a form into one table that has no keys outside of the primary key, but I can't seem to find anything that talks about how to add data to a multilevel database from a windows application.

What I have tried:

I have tried copious google searches and YouTube searches, but everything I've found either talks about pulling data from multiple tables into objects on a Form or sending data from a form to one table.

I'm not saying boo to that, because that's the most basic operation and most folks that are learning need to start at that point, but I'm past that at this point and can't seem to find a way through all of the absolute beginner tutorials.
Posted
Updated 24-May-19 12:59pm
v2
Comments
[no name] 24-May-19 17:22pm    
In case you need to insert a record in a table which has several foreign keys you need to make sure that every foreign key has a valid value. Now, a foreign key can be defined to allow <null> values, in this case it is easy, you can set the value to <null>. For the foreign keys which do not allow <null> you need to support a valid value, means a value which exists in the referenced table.

1 solution

The updating of the indexes is "transparent". So, your question boils down to "how to insert a record".

If your question is: how do I create a database with primary and secondary indexes, then that's another question / story.

If in the process of inserting a record you violate secondary index rules, then that's another topic again.

vb.net - How can I Insert data into SQL Server using VBNet - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900