与表中的插入值的asp.net查询 [英] asp.net query with insertion of values in a table
问题描述
假设我们在数据库三个表:
suppose we have three tables in the Database:
- tbl_companymaster(的company_id(PK),COMPANY_NAME)
- tbl_papermaster(paper_id(PK),paper_name,利率)
- tbl_rate(rate_id(PK),的company_id(FK),paper_id(FK),利率)
我们不得不解雇插入的查询按钮在asp.net中的点击使用C#语言。
we have to fire a query of insert on the clicking of a button in asp.net with c# language.
我们要插入的company_id(从tbl_companymaster),paper_id(从tbl_papermaster),速度(sfrom tbl_papermaster)到tbl_rate例:
we have to insert the company_id (from tbl_companymaster),paper_id(from tbl_papermaster),rate(sfrom tbl_papermaster) into tbl_rate Example:
tbl_companymaster:
tbl_companymaster:
company_id company_name
-----------------------------------
1 lalit and company
-------------------------------------
2 deepesah and co.
-----------------------------------
3 RP & Co.
-------------------------------------
tbl_papermaster:
tbl_papermaster:
paper_id paper_name rate
-------------------------------------------------
1 plain 400
------------------------------------------------
2 carbon 300
-------------------------------------------------
3 butter 500
tbl_rate:
tbl_rate:
rate-id company_id paper_id rate
---------------------------------------------------------------
1 1 1 400
--------------------------------------------------------------------
2 1 2 300
-----------------------------------------------------------------------
3 1 3 500
------------------------------------------------------------------------
4 2 1 400
-----------------------------------------------------------------------
5 2 2 300
---------------------------------------------------------------------
6 2 3 500
------------------------------------------------------------------------
请帮我适合codeI米的一个很大的麻烦与此code。
Please help me with the suitable code.I m in a great trouble with this code.
在此先感谢。
推荐答案
首先,你应该在table.As之间的了解Forign键和主键关系以及SQL加入。那么只有u能执行这么多的插入和数据绑定来查看。
First you should aware of Forign key and primary key relationships between the table.As well as the SQL Join. Then only u can perform this much of Insertions and DataBindings to view.
HTTP://www.$c$cproject.com/KB/数据库/ TableReader.aspx
http://msdn.microsoft.com /en-us/library/aa213227(v=sql.80).aspx
有关你的每家公司都必须uniquidentifier.Based上的company_id(从tbl_companymaster),设置Forign密钥paper_id(从tbl_papermaster),设置Forign键率(从tbl_papermaster)插入tbl_rate.Perform编码操作基于所述密钥关系。
For yours Each company must have uniquidentifier.Based on the company_id (from tbl_companymaster),set Forign Key for paper_id(from tbl_papermaster),set Forign key for rate(from tbl_papermaster) into tbl_rate.Perform the coding operation based on the Key Relationships.
首先明确有关系的话去做。这将是更好的。
First clear with Relationship then do it. It will be Better.
但愿这很有帮助...
Hope this may helpful...
这篇关于与表中的插入值的asp.net查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!