具有通用ID的字段 [英] Fields with Common ID's
问题描述
我需要在数据库中插入记录,但条件是:
例如:
当我在数据库中插入客户的某些详细信息时,我还需要存储其价值信息.因此,他的个人详细信息存储在一个表中,值存储在另一个表中.
现在我需要的是,例如,如果个人信息表中有一个ID字段,那么我应该在值信息表中有一个字段,该字段将存储与个人信息表中的ID相同的ID.
喜欢:
注意:请将这段代码粘贴到记事本中,并将其另存为abc.html,以便您可以查看表格和所需内容.谢谢
这是个人信息表.
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.
<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>
现在,这是< b> VALUE信息表.</b>
Now This is the <b>VALUE INFORMATION TABLE.</b>
<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>
现在我们可以看到个人信息表的 ID 字段与价值信息表的 Personal_ID 字段相同.
因此,每当我在相同ID中插入记录时,都应自动将其插入值信息表"中,而PersonalInformationTable.ID是数据库为我设置的自动递增字段.
任何帮助都是非常可观的.
谢谢.. :)
[修改:修复了前置标签]
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]
推荐答案
在用于将数据插入第一个表的同一SPROC中,如何存储数据,第二个表?
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?
亲爱的伊斯梅尔:
不,我没有使用任何S程序.
我正在使用插入查询在我的页面之一中插入数据,提交后将其重定向到该页面.我完美地插入了表单中的所有值,但我需要此字段用于修改目的,以便我可以将相同的个人信息与相同的值信息进行匹配.
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.
是PersonalInformationTable.ID
的问题是数据库为您设置的自动递增字段?
如果是这样,答案取决于您用来运行SQL语句的框架:ADO.NET? LINQ 2 SQL?实体框架?
请编辑您的问题并添加此信息,我们将尽力为您提供更多帮助.
尼克
Is the problem thatPersonalInformationTable.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
这篇关于具有通用ID的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!