Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to insert records in the database but the conditions are:

for e.g:
When i am inserting some detail of a customer in the database i need to store his value information also. So his personal details are stored in one table and values are stored in another.
Now what i require is that for example if there is an ID field in the personal information table, i should have a field in the value information table which will store the same ID as that from the personal information table.
Like:
Note:kindly paste this code in your notepad and save it as abc.html so that you can view the table and what is required.Thanks


This is the Personal Information Table.
XML
<table style="text-align:center" width="382" height="111" border="1">
  <tr bgcolor="#0099FF">
    <th>ID</th>
    <th>Name</th>
    <th>Age</th>
  </tr>

  <tr >
    <td bgcolor="#FFCC00">01</td>
    <td>Max</td>
    <td>26</td>
  </tr>

  <tr >
    <td bgcolor="#FFCC00">02</td>
    <td>Revan</td>
    <td>27</td>
  </tr>

  <tr>
    <td bgcolor="#FFCC00">03</td>
    <td>Khan</td>
    <td>28</td>
  </tr>
</table>



Now This is the <b>VALUE INFORMATION TABLE.</b>
XML
<table style="text-align:center" width="382" height="111" border="1">
  <tr bgcolor="#0099FF">
    <th>ID</th>
    <th>Personal_ID</th>
    <th>empno</th>
    <th>F01</th>
    <th>F02</th>
  </tr>

  <tr>
    <td>101</td>
    <td bgcolor="#FFCC00">01</td>
    <td>123</td>
    <td>1.01</td>
    <td>2.02</td>
  </tr>
  <tr>
    <td>102</td>
    <td bgcolor="#FFCC00">02</td>
    <td>124</td>
    <td>1.02</td>
    <td>6.32 </td>
  </tr>
  <tr>
    <td>103</td>
    <td bgcolor="#FFCC00">03</td>
    <td>125</td>
    <td>1.03</td>
    <td>1.256</td>
  </tr>
</table>



Now as we can see the ID field of the Personal Information Table is same like the Personal_ID field of the Value Information Table.
So whenever i insert a record in the same ID should be inserted in the Value Information Table automatically and PersonalInformationTable.ID is an auto-incrementing field which the database sets for me.


Any Help would be really appreciable.
Thanks.. :)

[Modified: fixed the pre tags]
Posted
Updated 2-Apr-10 19:25pm
v7

How about from within the same SPROC that you are using to insert the data into the first table, you also store data in the second table?
 
Share this answer
 
Dear Ismail:
No i am not using any S-procedure.
I am inserting the data using an insert query in one of my pages to which it is redirected after submission. I insert all the values perfectly of the form but i need this field for modification purpose so that i can match the same personal information with the same value information.
 
Share this answer
 
Is the problem that PersonalInformationTable.ID is an auto-incrementing field which the database sets for you?

If so, the answer depends on what framework you are using to run your SQL statements: ADO.NET? LINQ 2 SQL? Entity framework?

Please edit your question and add this information and we will try to help you more.

Nick
 
Share this answer
 
Dear Nicholas,
Yes, the problem you have specified is the basic problem. The ID field is auto-incrementing and that is the issue for me.. And about the framework i am not sure which one is implemented. :( ..
 
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