<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:IS315Database1ConnectionString %>" SelectCommand="SELECT Category.CategoryName, Product.ProductName, Product.ProductPrice, Product.ProductID, vendor.VendorID, vendor.VendorName FROM vendor INNER JOIN Product ON vendor.VendorID = Product.VendorID INNER JOIN Category ON Product.CategoryID = Category.CategoryID WHERE ([VendorID] = @vendor.VendorID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="VendorID" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
So I'm nearly 100% my error is coming from the end of the first line of code "WHERE ([VendorID] = @vendor.VendorID)"> "
Does anyone know how to fix this, I've seen a couple of the same questions involving scalars, none have fixed or I haven't been able to throw my situation in the same context. Thank you.
It seems that the issue is caused by lack of @vendor
parameter declaration, as Juan Carlos Oropeza suggested in his comment. You rejected his suggestion, but after analysing the code I got into the same conclusion, so I decided to post more explanatory answer.
You used @vendor
parameter in the query, but declared only @VendorID
parameter (unless You declare other parameters somewhere else).
When You declare ControlParameter
, the Name
property indicates the name of parameter used in the query. In the code You posted, the parameter is named VendorID
, so this name should be used in the query as well (with an additional @
character that indicates it's a parameter's name).
Try to change the end of the query to WHERE [VendorID] = @VendorID
.
For more information, take a look at: