I have a DetailView control with Edit enabled. the SelectQuery for the SqlDataSource is built dynamically and looks something like this:
Associated with this, is an UpdateQuery which looks something like this, with the parameters appropriately defined:
Heres the problem. When I attempt to update the DetailView form by changing one of the displayed fields, as soon as I click on the DetailView's Update link, the changes to the DetailView revert to the original record values; ie. the update does not occur.
However, if I hardcode the UpdateQuery's WHERE clause parameter to say the value of 1, then the update works correctly ie.
Could anyone please advise me on how to correctly define / populate the @InsuredPolicyTurnoverId parameter correctly so that the above works.
Please note that I am keen to retain using the multi table SELECT clause as this makes it simple to display the lookup fields. I am also keen on resolving this situation without having to define SQL Views, Stored procedures etc.
Happy to supply additional information on request, but hopefully there's enough here to solve.
TIA,
Steve Lewy
Solutions Developer
SimplyData
simplydata.com.au
(dont cut corners or you'll go round in circles)
The details of the above are probably not important; suffice to say, its a multi table construct because I want to include a number of read only lookup fields in the generated form.SelectQuery said:[tt]
sq = "SELECT I.NameOfInsured, IP.PolicyNumber, IP.PolicyCurrency, " +
" IPT.TurnoverFrom, IPT.TurnoverTo, IPT.InsuredPolicyTurnoverId " +
"FROM dbo.tblInsured I " +
"INNER JOIN dbo.tblInsuredPolicy IP " +
"ON I.InsuredId = IP.InsuredId " +
"INNER JOIN dbo.tblInsuredPolicyTurnover IPT " +
"ON IP.InsuredPolicyId = IPT.InsuredPolicyId " +
"WHERE InsuredPolicyTurnoverId = " + txtInsuredPolicyTurnoverId;
SqlDataSource4.SelectCommand = sq;
[/tt]
Associated with this, is an UpdateQuery which looks something like this, with the parameters appropriately defined:
UpdateQuery said:[tt]
UPDATE tblInsuredPolicyTurnover
SET TurnoverFrom = @TurnoverFrom,
TurnoverTo = @TurnoverTo
WHERE (InsuredPolicyTurnoverId = @InsuredPolicyTurnoverId)
[/tt]
Heres the problem. When I attempt to update the DetailView form by changing one of the displayed fields, as soon as I click on the DetailView's Update link, the changes to the DetailView revert to the original record values; ie. the update does not occur.
However, if I hardcode the UpdateQuery's WHERE clause parameter to say the value of 1, then the update works correctly ie.
correctly updating the first record;UpdateQuery said:[tt]
UPDATE tblInsuredPolicyTurnover
SET TurnoverFrom = @TurnoverFrom,
TurnoverTo = @TurnoverTo
WHERE (InsuredPolicyTurnoverId = 1)
[/tt]
Could anyone please advise me on how to correctly define / populate the @InsuredPolicyTurnoverId parameter correctly so that the above works.
Please note that I am keen to retain using the multi table SELECT clause as this makes it simple to display the lookup fields. I am also keen on resolving this situation without having to define SQL Views, Stored procedures etc.
Happy to supply additional information on request, but hopefully there's enough here to solve.
TIA,
Steve Lewy
Solutions Developer
SimplyData
simplydata.com.au
(dont cut corners or you'll go round in circles)