帮忙找原因:Gridview访问数据源失败
我的程序里,Gridview无法读出需要的数据,浏览器报错如下:
Server Error in '/All Together' Application.
--------------------------------------------------------------------------
关键字 'in' 附近有语法错误。
'=' 附近有语法错误。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: 关键字 'in' 附近有语法错误。
'=' 附近有语法错误。
而对应地方的代码是这样的,到底哪个地方错了,望高手赐教
string strCommand = "select ProductID,Name,ProductNumber,ListPrice from Production.Product";
strCommand += "where ProductSubCategoryID in ";
strCommand += "(select ProductSubcategoryID from Production.ProductSubcategory";
strCommand += "where ProductCategoryID = @ProductCategoryID)";
SqlProducts.SelectCommand = strCommand;