我的程序里,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;
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;
关键字 'in' 附近有语法错误
可能是in(里面没有值)
strCommand += "where ProductSubCategoryID in ";
strCommand += "(select ProductSubcategoryID from Production.ProductSubcategory";
strCommand += "where ProductCategoryID = @ProductCategoryID)"; “where”前面加个空格试了看看~
你检查自己的sql语句是否存在错误
问题已经解决了,是出在where附近没有空格,谢谢大家