Update Query in formview

G

Guest

Greetings all!

After a week of toiling I've finallay decided to post the code below with
hopes that someone can point out my error(s).

Basically I have a Gridview/Formview on a ASP.NEt 2.0 page.
When I select a record on the Gridview I'm presented with the corresponding
FormView Template for Editing. Works fine!

ItemTemplate in FormView works fine...Edit button takes me Edit Template!

However...

Upon clicking the Update button on the item Tempalte (With the associated
SqlDataSource associated below my data fails to update.)

I'm sure my error is obvious but I just cannot find it.


<asp:SqlDataSource ID="REACTOR_AHTs" runat="server"
ConnectionString="<%$
ConnectionStrings:REACTORConnectionString % %>"
ProviderName="<%$
ConnectionStrings:REACTORConnectionString.ProviderName %>"
OldValuesParameterFormatString="original_{0}"
SelectCommand=
"SELECT CaseCounter,
Condition_of_Animal,
TreatmentCardHistory
FROM Animal_Health_Records
WHERE (CaseCounter = @CaseCounter)"

UpdateCommand=
"UPDATE Animal_Health_Records
SET Condition_of_Animal = @Condition_of_Animal,
TreatmentCardHistory = @TreatmentCardHistory
WHERE (Animal_Health_Records.CaseCounter =
@original_CaseCounter)">

<DeleteParameters>
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="Condition_of_Animal" Type="String" />
<asp:parameter Name="TreatmentCardHistory" Type="String"
/>
<asp:ControlParameter ControlID="grdREACTOR"
Name="original_CaseCounter" PropertyName="SelectedValue" Type="Int32" />
</UpdateParameters>

<SelectParameters>
<asp:ControlParameter ControlID="grdREACTOR"
Name="CaseCounter" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
 
G

Guest

No visible errors.. the updates just fails to be posted. the formview simply
reverts to the ItemTemplate and datsa remains unchanged!
 
A

armand.widiatmo

Hi Marcial, try this & let me know if it still doesn't work

UpdateCommand=
"UPDATE [Animal_Health_Records] SET [Condition_of_Animal] = ?,
[TreatmentCardHistory] = ? WHERE
[Animal_Health_Records.CaseCounter] =?

<UpdateParameters>
<asp:parameter Name="Condition_of_Animal" Type="String" />
<asp:parameter Name="TreatmentCardHistory" Type="String "/>
<asp:parameter
Name="Animal_Health_Records.CaseCounter"Type="String"/>
</UpdateParameters>

n.b: check again the Animal_Health_Records.CaseCounter data type
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top