473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Parent-Child Table concept. [vb.net]

Hi,

I have created a form for sales bill information. I am using two tables, its
salient filds are as below.
1) Bill - Fields - bill_id,customer_id,tdate [ bill_id is auto
incremental ]
2) Itemtran - Fields - itemtran_id,bill_id,item_id,price [bill_id is not
allows null]

I am using datagrid for Itemtran table. in case of new bill creation , I
can't know new bill_id before updating data. As my itemtran table's field
bill_id doesn't accept null value, I have to replace bill_id . Temporary, I
set its allow null value true. But is there any proper method for above
task.

Any hints are appreciated.

Hardik Shah.
Jan 12 '06 #1
1 3503
Hi,

"Hardik Shah" <ha********@hotmail.com> wrote in message
news:eU**************@TK2MSFTNGP15.phx.gbl...
Hi,

I have created a form for sales bill information. I am using two tables,
its
salient filds are as below.
1) Bill - Fields - bill_id,customer_id,tdate [ bill_id is auto
incremental ]
2) Itemtran - Fields - itemtran_id,bill_id,item_id,price [bill_id is not
allows null]

I am using datagrid for Itemtran table. in case of new bill creation , I
can't know new bill_id before updating data. As my itemtran table's field
bill_id doesn't accept null value, I have to replace bill_id . Temporary,
I
set its allow null value true. But is there any proper method for above
task.

Ussully your pk column of the master DataTable is set to AutoIncrement and
seed to -1, so that there are temporary keys (negative ones) which will be
replaced with the real ones once you do a DataAdapter/TableAdapter.Update.

Then if there is a DataRelation between the two DataTable's
(DataSet.Relations.Add) and it's set to cascade updates (which is the
default, see also DataRelation.ChildKeyContraint.UpdateRule) then it will
auto. update the child's foreign key when the master's primary key has
changed.

So the fk for new child rows will take the temporary pk (if you bind in a
master-detail scenerio) and the fk's will also be updated with the new pk's
once the master table is updated

HTH,
Greetings

Any hints are appreciated.

Hardik Shah.

Jan 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul Gobée | last post by:
What is the parent element of a button (IE6 on Win, transitional mode)? Is it the BODY, the browser default stylesheet, or something else? Contra "body is parent-element": - Buttons with no...
5
by: Suzanne Vogel | last post by:
Hi, Given: I have a class with protected or private data members, some of them without accessor methods. It's someone else's class, so I can't change it. (eg, I can't add accessor methods to the...
9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
5
by: Zürcher See | last post by:
The Control class has the Parent property that is readonly. When the control is added to a controls collection of another control the Parent property refers to that control. "Who" set the Parent...
2
by: Roy | last post by:
Ok, this is incredibly annoying. Below I have an ImageButton and it's ImageButton_Click sub. See the 6 response.writes? The output for them is displayed below in asterisks. Question: What part of...
6
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I...
6
by: Ray Schumacher | last post by:
What is the feeling on using "parent" in a class definition that class methods can refer to, vs. some other organization ? Should all relevant objects/vars just be passed into the method as needed?...
2
by: Steven | last post by:
I have a page(pg1) which contains a select list (list1) in a form(form1) and an iframe(frame1), in this iframe is a page(pg2) with another select list(list2) in a form(form2) and I transfer the...
1
by: bnchs | last post by:
This is C code. I am trying to fill each node's Parent field with its parent because I am drawing nodes to the screen. However, I have not been able to get this working. Reading the output from the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.