[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.

Question
[x]
Attachment Details

Must declare scalar value for gridview update

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

Tags: Gridview Update Master Detail

In Visual Studio, I have created a Master/Detail drill down report that seems to work fine for viewing additional information about a record.  However, when I want to edit the details in the detail gridview, I get

the message Incorrect syntax near 'nvarchar'.
Must declare the scalar variable "@SchoolName"

How should this be done?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:techpreppetitionConnectionString %>" 
        SelectCommand="SELECT [SchoolName] FROM [tblHighSchools]"></asp:SqlDataSource>
 
 
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
        DataKeyNames="SchoolName" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="SchoolName" HeaderText="SchoolName" ReadOnly="True" 
                SortExpression="SchoolName" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:techpreppetitionConnectionString %>" 
        DeleteCommand="DELETE FROM [tblHighSchools] WHERE [SchoolName] = @SchoolName" 
        InsertCommand="INSERT INTO [tblHighSchools] ([ISDName], [SchoolName], [SchoolAddress], [SchoolCity], [SchoolState], [SchoolZip], [SchoolPhone], [PrinTitle], [PrinFirstName], [PrinLastName], [SchoolEnrollment], [ServiceArea], [ArticulationGrayson], [ArticulationNCTC], [CoordTitle], [CoordFirstName], [CoordLastName], [Coordinator Email]) VALUES (@ISDName, @SchoolName, @SchoolAddress, @SchoolCity, @SchoolState, @SchoolZip, @SchoolPhone, @PrinTitle, @PrinFirstName, @PrinLastName, @SchoolEnrollment, @ServiceArea, @ArticulationGrayson, @ArticulationNCTC, @CoordTitle, @CoordFirstName, @CoordLastName, @Coordinator_Email)" 
        SelectCommand="SELECT * FROM [tblHighSchools] WHERE ([SchoolName] = @SchoolName)" 
        UpdateCommand="UPDATE [tblHighSchools] SET [ISDName] = @ISDName, [SchoolAddress] = @SchoolAddress, [SchoolCity] = @SchoolCity, [SchoolState] = @SchoolState, [SchoolZip] = @SchoolZip, [SchoolPhone] = @SchoolPhone, [PrinTitle] = @PrinTitle, [PrinFirstName] = @PrinFirstName, [PrinLastName] = @PrinLastName, [SchoolEnrollment] = @SchoolEnrollment, [ServiceArea] = @ServiceArea, [ArticulationGrayson] = @ArticulationGrayson, [ArticulationNCTC] = @ArticulationNCTC, [CoordTitle] = @CoordTitle, [CoordFirstName] = @CoordFirstName, [CoordLastName] = @CoordLastName, [Coordinator Email] = @Coordinator_Email WHERE [SchoolName] = @SchoolName">
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="SchoolName" PropertyName="SelectedValue" 
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="SchoolName" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="ISDName" Type="String" />
            <asp:Parameter Name="SchoolAddress" Type="String" />
            <asp:Parameter Name="SchoolCity" Type="String" />
            <asp:Parameter Name="SchoolState" Type="String" />
            <asp:Parameter Name="SchoolZip" Type="String" />
            <asp:Parameter Name="SchoolPhone" Type="String" />
            <asp:Parameter Name="PrinTitle" Type="String" />
            <asp:Parameter Name="PrinFirstName" Type="String" />
            <asp:Parameter Name="PrinLastName" Type="String" />
            <asp:Parameter Name="SchoolEnrollment" Type="String" />
            <asp:Parameter Name="ServiceArea" Type="Boolean" />
            <asp:Parameter Name="ArticulationGrayson" Type="Boolean" />
            <asp:Parameter Name="ArticulationNCTC" Type="Boolean" />
            <asp:Parameter Name="CoordTitle" Type="String" />
            <asp:Parameter Name="CoordFirstName" Type="String" />
            <asp:Parameter Name="CoordLastName" Type="String" />
            <asp:Parameter Name="Coordinator_Email" Type="String" />
            <asp:Parameter Name="SchoolName" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ISDName" Type="String" />
            <asp:Parameter Name="SchoolName" Type="String" />
            <asp:Parameter Name="SchoolAddress" Type="String" />
            <asp:Parameter Name="SchoolCity" Type="String" />
            <asp:Parameter Name="SchoolState" Type="String" />
            <asp:Parameter Name="SchoolZip" Type="String" />
            <asp:Parameter Name="SchoolPhone" Type="String" />
            <asp:Parameter Name="PrinTitle" Type="String" />
            <asp:Parameter Name="PrinFirstName" Type="String" />
            <asp:Parameter Name="PrinLastName" Type="String" />
            <asp:Parameter Name="SchoolEnrollment" Type="String" />
            <asp:Parameter Name="ServiceArea" Type="Boolean" />
            <asp:Parameter Name="ArticulationGrayson" Type="Boolean" />
            <asp:Parameter Name="ArticulationNCTC" Type="Boolean" />
            <asp:Parameter Name="CoordTitle" Type="String" />
            <asp:Parameter Name="CoordFirstName" Type="String" />
            <asp:Parameter Name="CoordLastName" Type="String" />
            <asp:Parameter Name="Coordinator_Email" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="SchoolName" DataSourceID="SqlDataSource2" Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="ISDName" HeaderText="ISDName" SortExpression="ISDName" />
            <asp:BoundField DataField="SchoolName" HeaderText="SchoolName" ReadOnly="True" 
                SortExpression="SchoolName" />
            <asp:BoundField DataField="SchoolAddress" HeaderText="SchoolAddress" 
                SortExpression="SchoolAddress" />
            <asp:BoundField DataField="SchoolCity" HeaderText="SchoolCity" SortExpression="SchoolCity" />
            <asp:BoundField DataField="SchoolState" HeaderText="SchoolState" SortExpression="SchoolState" />
            <asp:BoundField DataField="SchoolZip" HeaderText="SchoolZip" SortExpression="SchoolZip" />
            <asp:BoundField DataField="SchoolPhone" HeaderText="SchoolPhone" SortExpression="SchoolPhone" />
            <asp:BoundField DataField="PrinTitle" HeaderText="PrinTitle" SortExpression="PrinTitle" />
            <asp:BoundField DataField="PrinFirstName" HeaderText="PrinFirstName" 
                SortExpression="PrinFirstName" />
            <asp:BoundField DataField="PrinLastName" HeaderText="PrinLastName" SortExpression="PrinLastName" />
            <asp:BoundField DataField="SchoolEnrollment" HeaderText="SchoolEnrollment" 
                SortExpression="SchoolEnrollment" />
            <asp:CheckBoxField DataField="ServiceArea" HeaderText="ServiceArea" SortExpression="ServiceArea" />
            <asp:CheckBoxField DataField="ArticulationGrayson" HeaderText="ArticulationGrayson" 
                SortExpression="ArticulationGrayson" />
            <asp:CheckBoxField DataField="ArticulationNCTC" HeaderText="ArticulationNCTC" 
                SortExpression="ArticulationNCTC" />
            <asp:BoundField DataField="CoordTitle" HeaderText="CoordTitle" SortExpression="CoordTitle" />
            <asp:BoundField DataField="CoordFirstName" HeaderText="CoordFirstName" 
                SortExpression="CoordFirstName" />
            <asp:BoundField DataField="CoordLastName" HeaderText="CoordLastName" 
                SortExpression="CoordLastName" />
            <asp:BoundField DataField="Coordinator Email" HeaderText="Coordinator Email" 
                SortExpression="Coordinator Email" />
            <asp:CommandField ShowEditButton="True" />
        </Fields>
    </asp:DetailsView>
[+][-]11/05/09 05:53 AM, ID: 25749407Expert Comment

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/12/09 01:25 PM, ID: 25809120Author Comment

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/16/09 09:19 AM, ID: 25831939Expert Comment

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/16/09 02:11 PM, ID: 25834753Author Comment

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/17/09 05:39 AM, ID: 25839494Expert Comment

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/17/09 05:40 AM, ID: 25839505Expert Comment

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/18/09 09:18 AM, ID: 25851984Author Comment

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/18/09 10:08 AM, ID: 25852841Author Comment

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/18/09 12:23 PM, ID: 25854339Expert Comment

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...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625