[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/04/2009 at 09:30AM PST, ID: 24871665 | Points: 500
[x]
Attachment Details

How to deal with a & in data field during an UpdateCommand

Asked by twestfall in Programming for ASP.NET, Visual Studio

Tags: asp.net

Does anyone know how to handle an UpdateCommand when the data being updated may contain special characters that will result in an error.  I normally can trap this in code behind but I'm wondering if it can be dealt with directly in ASPX code.

If you look at my code below, my SPCompany fied has data in the field like "DB & Sons"

This causes an error when doing the update.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ MyConnectionStrings:ConnectionString %>"
    ConflictDetection="CompareAllValues" 
    OldValuesParameterFormatString="original_{0}" 
    UpdateCommand="UPDATE SBTInvoice SET SpecNo = @SpecNo, SPCompany = @SPCompany, Project = @Project, SPContact = @SPContact, SalesMn = @SalesMn WHERE SBTInvoiceID = @original_SBTInvoiceID ">
    <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" Name="SalesMn" PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="SalesMn" Type="String" />
        <asp:Parameter Name="SpecNo" Type="String" />
        <asp:Parameter Name="SPCompany" Type="String" />
        <asp:Parameter Name="Project" Type="String" />
        <asp:Parameter Name="SPContact" Type="String" />
        <asp:Parameter Name="original_SBTInvoiceID" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
[+][-]11/05/09 06:15 AM, ID: 25749632

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 06:53 AM, ID: 25750042

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/12/09 05:21 PM, ID: 25810554

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625