Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi to all!

here i have a little problem

i create two froms
form1
form2

and i have two tables in sql server
table1
table2

and in table1 two fields
t1 (PK)
t2


and in table2 two fields
t1 (FK)
t3


in form1 i have two textbox use to insert value in table1

and now to update table2 which has t1 has (FK)
Posted
Comments
Md. Rashim Uddin 23-Aug-11 5:42am    
Could i know what is your problem I mean in which portion you are getting stuck??
Herman<T>.Instance 23-Aug-11 5:50am    
you cannot update table 2. When data is new in table 1 the FK reference does not exist in table2 so an insert should be done in stead of an update!

1 solution

//write first insertion statement using this query


insert into table1(t1,t2)values('"+textBox1.text+"','"+textBox2.text+"')

//then 2nd insertion using this query


insert into table2(t1,t3)values('"+textBox1.text+"','')

//if you want to add 2nd field in table2 then directly insert using the above insert query or update the 2nd table
 
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