|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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. Hi,
Show quoteHide quote "Hardik Shah" <har_sha***@hotmail.com> wrote in message Ussully your pk column of the master DataTable is set to AutoIncrement and news:eUyRWt3FGHA.2212@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. > 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 Show quoteHide quote > Any hints are appreciated. > > Hardik Shah. > >
VS2003 to VS2005 Conversion
Email attachments? Module and Class Probably an intro question -> starting window over? calling form_load? Copying DataRows to another DataTable win32 dll vb.net pointers receiving data - HELP MDI's Declaring Variables Within a If Steatement Open pdf file with button in VB 2005 Locking Application to HDD Sr.No. |
|||||||||||||||||||||||