我是SQl的新手,我正在运行示例,我想知道是否有人可以帮助我提供一段代码。我知道我的一个问号存在语法错误,但我无法弄清楚它的位置或为什么会发生这种情况。
这是我的代码:
-
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Overline="True"
Font-Size="X-Large" Font-Underline="True" Text="Product Information Log"></asp:Label>
<br />
<br />
</div>
<asp:GridView ID="GridView1" runat="server"
AllowSorting="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display." ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#808080" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="CICNumber" HeaderText="CICNumber"
SortExpression="CICNumber" />
<asp:BoundField DataField="ItemName" HeaderText="ItemName"
SortExpression="ItemName" />
<asp:BoundField DataField="ItemNumber" HeaderText="ItemNumber"
SortExpression="ItemNumber" />
<asp:BoundField DataField="PLUNumber" HeaderText="PLUNumber"
SortExpression="PLUNumber" />
<asp:BoundField DataField="PackSize" HeaderText="PackSize"
SortExpression="PackSize" />
<asp:BoundField DataField="CaseCost" HeaderText="CaseCost"
SortExpression="CaseCost" />
<asp:BoundField DataField="UnitRetailCost" HeaderText="UnitRetailCost"
SortExpression="UnitRetailCost" />
<asp:CommandField ShowDeleteButton="true" />
<asp:CommandField ShowEditButton="true" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="Green" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ProductInfoConnectionString1 %>"
DeleteCommand="DELETE FROM [tblProductInfo] WHERE [UserID] = ?"
InsertCommand="INSERT INTO [tblProductInfo] ([CICNumber], [ItemName], [ItemNumber], [PLUNumber], [PackSize], [CaseCost], [UnitRetailCost]) VALUES (?, ?, ?, ?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:ProductInfoConnectionString1.ProviderName %>"
SelectCommand="SELECT [CICNumber], [ItemName], [ItemNumber], [PLUNumber], [PackSize], [CaseCost], [UnitRetailCost] FROM [tblProductInfo]"
UpdateCommand="UPDATE [tblProductInfo] SET [ItemName] = ?, [ItemNumber] = ?, [PLUNumber] = ?, [PackSize] = ?, [CaseCost] = ?, [UnitRetailCost] = ?, WHERE [CICNumber] = ?">
<DeleteParameters>
<asp:Parameter Name="CICNumber" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ItemName" Type="String" />
<asp:Parameter Name="ItemNumber" Type="Int32" />
<asp:Parameter Name="PLUNumber" Type="Int32" />
<asp:Parameter Name="PackSize" Type="String" />
<asp:Parameter Name="CaseCost" Type="Int32" />
<asp:Parameter Name="UnitRetailCost" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CICNumber" Type="Int32" />
<asp:Parameter Name="ItemName" Type="String" />
<asp:Parameter Name="ItemNumber" Type="Int32" />
<asp:Parameter Name="PLUNumber" Type="Int32" />
<asp:Parameter Name="PackSize" Type="String" />
<asp:Parameter Name="CaseCost" Type="Int32" />
<asp:Parameter Name="UnitRetailCost" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</form>
答案 0 :(得分:2)
你有
[UnitRetailCost] = ?, WHERE [CICNumber] = ?
在update语句的末尾,需要删除逗号:
[UnitRetailCost] = ? WHERE [CICNumber] = ?