Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have taken 2 tables -> 1)Dayprogram1
2)TimeAllocate

and i have taken relation both of them like
MIDL
con = new SqlConnection("Initial Catalog=customer;data source=arun;Integrated Security=SSPI");
            da = new SqlDataAdapter("Select * from dayprogram1", con);
            da1 = new SqlDataAdapter("Select * from TimeAllocate where code=100", con);
            ds = new DataSet();
            da.Fill(ds, "dayprogram1");
            da1.Fill(ds,"TimeAllocate");
            dr = new DataRelation("parent", ds.Tables["dayprogram1"].Columns["code"], ds.Tables["TimeAllocate"].Columns["code"]);
            ds.Relations.Add(dr);
            dr.ChildKeyConstraint.DeleteRule = Rule.None;
            dr.ChildKeyConstraint.UpdateRule = Rule.None;
            loaddata();

Now i want to enter a record into TimeAllocate Table...I am not getting an idea...any one help me
Posted
Updated 14-Dec-10 23:18pm
v2
Comments
Toniyo Jackson 15-Dec-10 5:18am    
Always write your code inside code block
Abdul Quader Mamun 15-Dec-10 5:34am    
Why doing thing complex in your code.

1 solution

First enter data in child table, get the Primary key and insert data into parent table with that primary key.
 
Share this answer
 
Comments
senguptaamlan 15-Dec-10 5:33am    
I think the process will be reversed....the relation is parent -> child not child <- parent

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