this is the query:
this._adapter.InsertCommand.CommandText = @"INSERT INTO [P_OrdiniRighe] ([IdOrdine], [CodiceArticoloInterno], [CodiceArticoloEsterno], [CodiceFinitura], [CodiceVariante], [Quantita], [DataConsegna], [QuantitaConsegnata], [UM], [Prezzo], [Note], [QuantitaImpegnata]) VALUES (@IdOrdine, @CodiceArticoloInterno, @CodiceArticoloEsterno, @CodiceFinitura, @CodiceVariante, @Quantita, @DataConsegna, @QuantitaConsegnata, @UM, @Prezzo, @Note, @QuantitaImpegnata);<br />
SELECT IdRigaOrdine, IdOrdine, CodiceArticoloInterno, CodiceArticoloEsterno, CodiceFinitura, CodiceVariante, Quantita, DataConsegna, QuantitaConsegnata, UM, Prezzo, Note, QuantitaImpegnata FROM P_OrdiniRighe WHERE (IdRigaOrdine = SCOPE_IDENTITY())";
this._adapter.UpdateCommand.CommandText = @"UPDATE [P_OrdiniRighe] SET [IdOrdine] = @IdOrdine, [CodiceArticoloInterno] = @CodiceArticoloInterno, [CodiceArticoloEsterno] = @CodiceArticoloEsterno, [CodiceFinitura] = @CodiceFinitura, [CodiceVariante] = @CodiceVariante, [Quantita] = @Quantita, [DataConsegna] = @DataConsegna, [QuantitaConsegnata] = @QuantitaConsegnata, [UM] = @UM, [Prezzo] = @Prezzo, [Note] = @Note, [QuantitaImpegnata] = @QuantitaImpegnata WHERE (([IdRigaOrdine] = @Original_IdRigaOrdine) AND ([IdOrdine] = @Original_IdOrdine) AND ([CodiceArticoloInterno] = @Original_CodiceArticoloInterno) AND ([CodiceArticoloEsterno] = @Original_CodiceArticoloEsterno) AND ([CodiceFinitura] = @Original_CodiceFinitura) AND ([CodiceVariante] = @Original_CodiceVariante) AND ([Quantita] = @Original_Quantita) AND ([DataConsegna] = @Original_DataConsegna) AND ([QuantitaConsegnata] = @Original_QuantitaConsegnata) AND ([UM] = @Original_UM) AND ([Prezzo] = @Original_Prezzo) AND ([Note] = @Original_Note) AND ([QuantitaImpegnata] = @Original_QuantitaImpegnata));<br />
SELECT IdRigaOrdine, IdOrdine, CodiceArticoloInterno, CodiceArticoloEsterno, CodiceFinitura, CodiceVariante, Quantita, DataConsegna, QuantitaConsegnata, UM, Prezzo, Note, QuantitaImpegnata FROM P_OrdiniRighe WHERE (IdRigaOrdine = @IdRigaOrdine)";
They are generated automatically...
This is the function for updating e inserting
public static void UpdateParentChildObject(<br />
DataTable oParentTable, DbDataAdapter oParentTableAdapter,<br />
DataTable oChildTable, DbDataAdapter oChildTableAdapter)<br />
{<br />
DataTable tblChildDeleted = null;<br />
DataTable tblChildAdded = null;<br />
DataTable tblChildModified = null;<br />
<br />
try<br />
{<br />
tblChildDeleted = oChildTable.GetChanges(DataRowState.Deleted);<br />
if (tblChildDeleted != null)<br />
oChildTableAdapter.Update(tblChildDeleted);<br />
<br />
oParentTableAdapter.Update(oParentTable);<br />
oParentTable.AcceptChanges();<br />
<br />
tblChildAdded = oChildTable.GetChanges(DataRowState.Added);<br />
if (tblChildAdded != null)<br />
oChildTableAdapter.Update(tblChildAdded);<br />
<br />
tblChildModified = oChildTable.GetChanges(DataRowState.Modified);<br />
if (tblChildModified != null)<br />
oChildTableAdapter.Update(tblChildModified);<br />
<br />
oChildTable.AcceptChanges();<br />
<br />
}<br />
finally<br />
{<br />
if (tblChildDeleted != null)<br />
tblChildDeleted.Dispose();<br />
<br />
if (tblChildAdded != null)<br />
tblChildAdded.Dispose();<br />
<br />
if (tblChildModified != null)<br />
tblChildModified.Dispose();<br />
}<br />
}
Tell me if you need more information
|