.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Populate foreign key in the table

Posted By:      Posted Date: October 24, 2010    Points: 0   Category :ASP.Net

I need to populate the foreign key coloum in the table.

i have three tables















I am instering data in PATIENT DETAILS and IMPLANT DETAILS table on the same page from single button click .

I have a foreign key on the table IMPLANT DETAIL (productID) which i populate through the value on the dropdownlist .

What my problem is how will i populate foreign key (ptID) in IMPLANT DETAIL table. When ptID (PATIENT DETAIL) will also be generated from the same button click at almost of the same time.

View Complete Post

More Related Resource Links

populate specific data from table

I am trying to build an application.I have table in my database named tbl_customer.I am able to display all the customers information using MVC i.e Name,Designation, Address, PhoneNumber, Sex etc.Now I Want To Display Customer only Having Sex "Female" (Sort Out Data From tbl_customer)How I Can Do This???I Am New To Asp.net.. I Am Using VS 2010, SQL Server 2005Help In This Context, Appreciated In Advance..Regards

How to use parameter from Dropdownlist to populate Rep. Table

I successfully have populated a dropdownlist from a database. Now I need to create a sort of a Master/Detail situation - based on the selection in the DropDownlist, I need to populate a Repeating table. I just can't find any examples or tutorials on how to do this. I've tried stuff till my fingers were bleeding. Can someone help me figure this scenario out, please?

How to know foreign key references for a table

Hi, For a parent table, having a parent id, is it possible to know all the child tables? for e.g if TABLE1 has PK1 as primary key, TABLE2 has PK2 which is a foreign key refering to TABLE1 and TABLE3 also has a foreign key referecing TABLE1 and many others.. is it possible to know all the child tables for table TABLE1?? Thanks,

how to auto-fill and populate a repeating table from other sources?

I have a repeating table and users will enter values to a column. With the column, I would like to auto-generate a list of checkboxes for user to check in another place on the form (any control?)? Seems in Infopath, you can not loop a list; and you can not insert item with actions to a repeating table?

Populate Sql Table

I'm really unsure of what was the best title for this question, It's a rather complex SQL Insert Statement, at least I know it's way beyond anything i've seen. I'm planning on using the SQL Agent to run this Import once a day. Here are the Tables: Submittal                                       Default Values Date                                              City Hour (1-24)                                    Minimum Minimum                                        Maximum Maximum                  &nb

Search data from sharepoint list and populate repeating table (Seach text should be entre in first f


Hi All,

I am newbie to infopath.

I have assignment to search data from sharepoint list and display it to repeating table. Below is the case in detail.

i. User enter search text in first textbox of repeating table.

ii. After text enter you will Enter or click tab button.

iii. As user press Tab /Enter, the other textboxes of repeating table will populate with data automatically.

iv. If searched data rows are more then one, then dynamically add new row's in repeating table and  show searched data.

I am working at offical assignment and it's deadline is very tough. i had made extensive search at google and msdn forum but unable to accomplish. I would appreciate and thanks is some provide me solution in form to a small infopath application and code snippet.




Inserting null value into foreign key table with allow null enabled


Hey guys, 

I have 2 table Table A, Table B.

Table A - Parent Table

ID - Uniqueidentifier not null(PK)

Table B -Child Table              

ID - uniqueidentifier null(FK, TableA)

I have a stored procedure to insert data into Table B, but when I tried to insert a null value into column ID of table B, this error came up:

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The conflict occurred in database "database name", table "table A", column 'ID'.

The statement has been terminated.

The insert statement in asp.net is like so:

sqlcommand.parameter.add(New Sqlparameter("ID", Nothing))

I am guessing adding nothing to the null value column is the problem, but i don't know how to fix it... can any1 help me?


The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA". The co

Add new record to a sql table that has a foreign key relationship using infopath form



it's me again.

i want to know how can i add new records to a sql database table that has a foreign key relationship with another table using infopath form.

i have created a blank form based on database

i have all my fields and the "add new" button already in the form.

i have the username and the userid filled in automatically when the user opens the form.

when i fill in the form with new data and click submit. it gives me this error:

Field or group: BE_CODE
Error: Only integers allowed

this "BE_CODE" field has to be filled in the database table, it can not be null. but it must not be filled in by the user it self. and it is a repeating table so it can not be auto increment.

how can this field also be filled in the database table?

Creating table records with foreign key constraints/Separate controllers?


I have multiple tables that are all linked back to a central table with foreign keys. I want to be able to create a new record in table 2, but I'm having trouble because I don't know how to create a new instance of table 2's record while referencing the ID of the record it will be tied to.


Populate ASP Table from Text File


Hey Guys, new developer here. I'm trying to populate a ASP table dynamically. This is what I'm trying to do.

I have table with 1 row and 4 cells. I want to import information from a text file into the various cells. Each line of the text file is what I want to go into each cell.

For example if the text file reads:





I want each line to go into each cell. Is this possible, or will I need to create a SQL Server table and read from that? THANKS!

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint


The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "fk_Allergy". The conflict occurred in database "MSCPROJECT", table "dbo.Severity", column 'SeverityCode'.

multiple foreign keys to same table and same column


I am working with two Tables. Table A contains Id, Names. Table B  keeps only the reference to table A by InventoryID1, InventoryID12, InventoryID3.

Table A

Table B

I need a select statement to pull up all items from table B, showing the InventoryID 1, 2, 3 by their corresponding Name on Table A  

At first I thought this would be a simple inner join statement, which it does work when only InventoryID1 is involved
select * from Inventory
inner join Menu On (Inventory.InventoryId1 = Menu.Inventory)

The problem arises when I try to obtain the Inventory Name from Table A for the second or third (InventoryID2 or InventoryID3) from Table B. So basically, my problem is how to request a second or third Inventory.Name in the same select statement

What is crosswalk table and how to create and populate them?


Hi All,

i have some excell spreadsheets and i have to create crosswalk tables and have to populate them. but before that i wanna know what is crosswalk table.

Thanks for any help.

How can i populate repeating table with web service



I have created a repeating table with three columns, first column require some calculation (hyperlink).

I have a web service that returns multiple records onload, how can i fill repeating table with the data without code.


Note: I cannot simply drag WebService repeating group on form because i have to do some calculation on field one.

Dataset has one field, populate a table 2 columns wide n rows deep



A dataset returns a single field of child names, instead of presenting this as a single column table, I would like it to be multi column.

Dataset returns:


I would like to display it as:

Child1 Child2 
Child3 Child4


Help: populate Html.DropDownList from table data? [Linq to SQL model]


I have two tables, Users and Roles.  The roles table is a reference table for the different roles of my site (RoleId and RoleName columns). The Users table contains profile data for each user, including a RoleId column that is FK'd back to the Roles table [RoleId].

Both tables are in a Linq to SQL model.

I have an edit page created which lists all the profile values of a user.  The edit page inherits the User model.  One of the editable values is the RoleId field.  I want to set this up to be a drop-down list that contains items labeled using the RoleName column of the Roles table, and matched with values of RoleId.

How can I achieve this?

New To SQL - need to populate a table from a TXT file


i am trying to populate a table from a txt file

this is the query i wrote

USE [Resolution & Ordenances]
INSERT INTO Resolutions (ResolutionID,ResolutionDate,ResolutionDescription)
OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};

i am getting an error msg

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

any idea ?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend