PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Master Detail InsertCommand
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Master Detail InsertCommand
![]() |
Master Detail InsertCommand |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I am developing an application that accesses a Foxpro database (.dbf files) with two tables, the master table (customers) has a field (id) which is primary key. The detail table (orders) has a primary key formed by the fields: customerid, orderid. The order id is a not automatic counter for every customer orders. Ex: CustomerID 1 - OrderID 1 CustomerID 1 - OrderID 2 CustomerID 2 - OrderID 1 CustomerID 2 - OrderID 1 CustomerID 2 - OrderID 2 I don't know how to build the InsertCommand for the Orders table. Those are the problems I have: - To know the order id I need to query the database before inserting. Can I make an InsertCommand with two commands? The first queries the database for orderid and the second inserts the record. - I can not make a single query because I think Foxpro does not allow sentences like this: INSERT INTO orders (customerid, orderid) VALUES (1, SELECT max(orderid)+1 WHERE customerid=1) I suppose if I don't relay on InsertCommand and handle the insertions myself I will have more control but I wanted to take advantage of ado.net automatic updates with insertcommand. Thank you very much! |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

