adding new with hierarchical recordset and datagrid

adding new with hierarchical recordset and datagrid

Post by Tjomm » Thu, 27 Jun 2002 20:38:23



I have a table 'product' the parent, and 'ingredient' as childtable.
I use a master/detail solution (created by the vb application wizzard).
textboxes, a combobox (for navigating through the recordset, rstMix), and a
datagrid.

Everything works just fine as long as i stay away from adding
(rstMix.addnew) mnew records (parent and child) .

The error comes when I try to save...

The errormessages (following: rstMix.UpdateBatch adAffectAll) are:
"You cannot add or change a record because a related record is required in
table 'product'."
and then
"Index or primary key cannot contain a Null value."

Below is the code i use for data-retrieval.

 Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\...

  Set rstMix = New Recordset
    rstMix .StayInSync = True
    rstMix .Open "SHAPE {SELECT * FROM Products Order by UProdukt}
                            AS ParentCMD
                            APPEND ({SELECT * FROM ingredientOrder by
LProdukt }
                            AS ChildCMD
                            RELATE UProdukt TO UProdukt)"
                            , db, adOpenDynamic, adLockOptimistic

Please help befor i go crazy,
Susanne

 
 
 

1. adding new, with hierarchical recordset and datagrid

I have a table 'product' the parent, and 'ingredient' as childtable.
I use a master/detail solution (created by the vb application wizzard).
textboxes, a combobox (for navigating through the recordset, rstMix), and a
datagrid.

Everything works just fine as long as i stay away from adding
(rstMix.addnew) mnew records (parent and child) .

The error comes when I try to save...

The errormessages (following: rstMix.UpdateBatch adAffectAll) are:
"You cannot add or change a record because a related record is required in
table 'product'."
and then
"Index or primary key cannot contain a Null value."

Below is the code i use for data-retrieval.

 Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\...

  Set rstMix = New Recordset
    rstMix .StayInSync = True
    rstMix .Open "SHAPE {SELECT * FROM Products Order by UProdukt}
                            AS ParentCMD
                            APPEND ({SELECT * FROM ingredientOrder by
LProdukt }
                            AS ChildCMD
                            RELATE UProdukt TO UProdukt)"
                            , db, adOpenDynamic, adLockOptimistic

Please help befor i go crazy,
Susanne

2. filter by selection semi-functional in adp's?

3. Hierarchical recordsets and adding new rows

4. Query problem

5. Where to get plantable information about runtime queries!?!

6. DataGrid+Shape+Hierarchical Recordset

7. Web Kit for SCO or Linux?

8. Hierarchical Recordset - Add empty fields???

9. Adding New Records With DataGrid

10. adding new record in datagrid

11. How to add new records using DataGrid control.

12. ADO and Datagrid Add new record problem ??