PDA

Click to See Complete Forum and Search --> : datagrid


Lisa B
Nov 9th, 2000, 12:42 PM
I have a datagrid with data coming from 2 tables which are joined on 1 field. When a new record is inserted into the grid, the datagrid is trying to insert 1 record into each table in the query. I only want the main table to be updated. The same kind of thing happens when a record is deleted. The data is deleted from both tables rather than just the main table. Is there a way to make sure only the data from the main table is affected?

AdrianH
Nov 10th, 2000, 06:29 AM
Hi Lisa.

Can you provide a bit more info? Is your DataGrid bound to a Data Control that is the result of a table or SQL call?

If you can post some code on how your DataGrid is established, then we can check it out and see how to solve your problem.

Regards
Adrian.

Lisa B
Nov 10th, 2000, 08:19 AM
Adrian,

You had requested more information about how the data is loaded into the control. Well, I create a recordset (rs in the code below). I have an ADODC control and the recordset of the ADODC control is set to be the recordset I create (rs). The datasource of the grid is set to be the ADODC control. Below I have the basic sqlstr I use to retrieve the data from SQL Server.

cmd.CommandText = "SELECT part_info.id, part_info.bom_id, bom.id, bom.bom_code_id, bom.mfg_pt_id AS 'Manufacturer Part' FROM part_info LEFT JOIN bom ON bom.id = part_info.bom_id WHERE bom.bom_code_id = 2 ORDER BY bom.mfg_pt_id"

rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockOptimistic

Set ADOBom.Recordset = rs

Thanks for your help.

Lisa

KMcKenzie
Nov 10th, 2000, 04:24 PM
Instead of relying on the grid for deletes and update etc use SQL code.