gpt4 book ai didi

c# - SQLException (0x80131904) : Incorrect syntax near '?'

转载 作者:太空宇宙 更新时间:2023-11-03 10:34:36 25 4
gpt4 key购买 nike

我是 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>

最佳答案

你有

[UnitRetailCost] = ?, WHERE [CICNumber] = ?

更新语句末尾的逗号需要去掉:

[UnitRetailCost] = ? WHERE [CICNumber] = ?

关于c# - SQLException (0x80131904) : Incorrect syntax near '?' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28333246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com